怎么了!
我正在尝试发送带有json参数的请求,但我不明白为什么在服务器端 该参数未发送
let res = fetch("http://localhost:1000/vacations/" + vacation.id, {
method: "DELETE",
headers: { "Authorization": localStorage.token },
body: { "picture": vacation.picture }
})
我正在尝试在服务器端的参数中查看图片
我在node.js服务器中使用中间件express.json
仍然我无法获得此参数:(
答案 0 :(得分:1)
您可以使用JSON.stringify
发送字符串化正文。
const res = fetch(`http://localhost:1000/vacations/${vacation.id}`, {
method: "DELETE",
headers: {
Authorization: localStorage.token
},
body: JSON.stringify({
picture: vacation.picture
})
})