javascript - 响应没有从 Node js 后端返回
问题描述
我从我的 React 应用程序将请求发送到节点 js 后端,但它没有响应请求,它也确认更改。我使用 Redux 和 Redux-Thunk,我想在从后端获得响应后调度一个动作,但后端发生了变化但没有'不响应任何数据,它不起作用。
我想更新用户信息,然后发送一个动作来更新 redux 存储中的数据,但是这个更新只发生在后端,我的意思是在后端更新之后动作不会调度..
ITS MY REACT CODE
export const updateDetails = (name, email, password) => {
const locals= JSON.parse(localStorage.getItem("user"));
const token = locals["token"];
const newDetails = { name, email, password };
const everyThing = {
newDetails,
id: locals["id"],
};
const newEvery = JSON.stringify({ everyThing });
return (dispatch) => {
dispatch(profileUpdateRequest());
fetch("users/auth/updateProfile", {
method: "PUT",
headers: {
authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
body: newEvery,
}) //After That Not Dispatch any action even nothing work
.then((res) => {
console.log(res); // Even Doesn't log this
dispatch(updateProfileUI(newDetails));
})
.catch((err) => {
dispatch(updateProfileFail(err.message));
});
};
};
它适用于另一个请求,但不适用于这个请求
解决方案
推荐阅读
- python - 视图 ProjectManagementapp.views.product_insert_view 没有返回 HttpResponse 对象。它返回 None 而不是
- javascript - rss 格式不正确(无效令牌) - ReactJS
- flutter - 如何将数据传递给有状态的小部件
- laravel - Laravel:生产路径和本地路径的区别;需要使用公共/
- python - 如何使用 cpython 将结构数组传递给 DLL 函数?
- python - 如何在python中将字典与字典分组?
- c# - 如何从 Azure Functions v2 中的请求正文获取图像数据并转换为 Stream
- javascript - 询问 javascript 粘贴事件以获取图像数据
- javascript - 如何检查使用了 Raspberry Pi 上的哪些引脚
- reactjs - Onclick 选择的 MenuItem 无法正常工作