这是我的 MERN 应用程序中最奇怪的事情。当我从 Postman 向我的 api 执行 PUT 时,它可以工作并更新我的 api 和 mongoDB。在前端,即使控制台日志显示正确的值并且 url 相同,它也不会更新 api?任何帮助或指导将不胜感激......现在已经玩了好几天了。
邮递员证明更新工作
我的 axios 的代码如下:
handlePlayerSubmit(id, player) {
console.log('This is the id: ' + id);
console.log('This is the player: ' + player);
let apiUrl = 'http://localhost:3001/api/teams';
//sends the id and new author/text to our api
axios.put(`${apiUrl}/${id}`, player).catch(err => {
console.log(err);
});
}
所以我知道它是由于控制台日志而触发的……不知道为什么它不更新 api?
它也不是 console.logging 一个错误。
开发工具中的网络屏幕截图
网络选项卡的标题: