簡體   English   中英

我正在嘗試使用 json 參數發送請求

[英]i am trying to send a request with json parameters

這是怎么回事!

我正在嘗試使用 json 參數發送請求,但我不明白為什么在服務器端沒有發送參數

let res = fetch("http://localhost:1000/vacations/" + vacation.id, {
            method: "DELETE",
            headers: { "Authorization": localStorage.token },
            body: { "picture": vacation.picture }
        })

我正在嘗試在服務器端查看參數中的圖片

我在 node.js 服務器中使用中間件 express.json

但我仍然無法獲得此參數:(

您可以使用JSON.stringify發送字符串化正文。

  const res = fetch(`http://localhost:1000/vacations/${vacation.id}`, {
      method: "DELETE",
      headers: {
        Authorization: localStorage.token
      },
      body: JSON.stringify({
          picture: vacation.picture
      })
  })

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM