在ReactJS中发送POST请求时遇到一些麻烦 我的减速器看起来像这样:
export const addTodo = todo => async (dispatch, getState) => {
let URL = "https://uxcandy.com/~shapoval/test-task-backend/v2/create/?developer=Nazar";
const { username, text, email } = todo;
const data = {
username: username,
text: text,
email: email
};
console.log(JSON.stringify(data));
await fetch(URL, {
method: "POST",
headers: { contentType: "application/json" },
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => {
dispatch({ type: "ADD_TODO", payload: data });
})
.catch(err => {});
};
中的图片一样发送POST请求
感谢您的帮助,祝您有美好的一天!