我正在构建一个Mern项目,只要我测试POST(将电影添加到购物车),我就会收到此错误,不知道它来自此错误的位置,尝试了一切。
这是我的 Client.js
"use strict"
import React from 'react';
import {render} from 'react-dom' ;
import {Provider} from 'react-redux';
import {Router,Route,IndexRoute, browserHistory} from 'react-router';
import {applyMiddleware, createStore,compose} from 'redux';
import thunk from 'redux-thunk'
import { createLogger } from "redux-logger";
import reducers from './reducers/index';
import {addToCart} from './actions/cartActions';
const middleware =applyMiddleware(thunk, createLogger());
const store = createStore(reducers, middleware);
我在 moviesActions.js
上的功能import axios from 'axios';
export function postMovies(movie){
return function (dispatch){
axios.post("/movies",movie)
.then(function(response){
dispatch({type:"POST_MOVIE", payload:response.data})
})
.catch(function(err){
dipsatch({type:"POST_MOVIE_REJECTED", payload:"there was an error while posting a new movie"})
})
}
}