我有一个带有python后端的react应用程序,该应用程序似乎可以很好地处理每个请求,但每次尝试对它执行PUT请求时都会给我以下错误:
Response {type: "cors", url: "http://localhost:5000/api/v1.0/project_logs/123456789", redirected: false, status: 500, ok: false, …}
body: (...)
bodyUsed: false
headers: Headers {}
ok: false
redirected: false
status: 500
statusText: "INTERNAL SERVER ERROR"
type: "cors"
url: "http://localhost:5000/api/v1.0/project_logs/123456789"
我的Express服务器上已经安装了cors。这是代码失败的地方:
export function addProjectLog(proj, state) {
let url = config.base_url + `/projects/${proj._id['$oid']}`;
return fetch(url, {
method: 'PUT',
headers: {'Content-Type': 'application/json', 'Authorization': 'Bearer ' + getUserToken() },
body: JSON.stringify({
project_log: {
description: state.description
}
})
})
.then(res => console.log(res))
.then(data => { return data })
.catch(err => console.log(err));
}
有人可以帮我解决这个问题吗?