Redux Post Request失败,状态代码为404



我正试图在使用axios的redux应用程序中向网络上的本地主机发出请求。这是请求代码:

export function createAccount(userInfo){
return async (dispatch) => {
try {
const resp = await axios.post(`${BASE_URL}/signup`, userInfo);
localStorage.setItem('token', resp.data.token);
dispatch({ type: types.SIGN_UP });
} catch(err) {
console.log('Sign Up Error:', err.message);
}
}
} 

以下是显示的错误:

Sign Up Error: Request failed with status code 404

另一个可能的原因可能是发送的参数名称与REDUX端的预期参数名称不匹配(操作(。更好地提供减速器的代码和行动索引。在我的案例中,POST请求得到404,当我检查Headers(在Network下(时,我发现request Payload是空的。原因如下:

const data = {
linkIdCampaign,
linkIdMix
}
this.props.onAddLink(data);

前端部分上的不对应于:

return axios.post("http://localhost:5000/YOUR_URL", { newLink, newMix})
.then(response => {

在动作索引中。

最新更新