javascript 如何在PATCH请求中更新阵列?[已关闭]

jdzmm42g  于 2023-02-15  发布在  Java
关注(0)|答案(1)|浏览(119)

8小时前关门了。
Improve this question

[{
  "title": "Todo Sample - 1",
  "description": "Prepare ReactJS interview questions and answers.",
  "dueDate": "2023-02-18",
  "tag": ["Prepare", "learn"],
  "status": "open",
  "timstamp": "2/14/2023, 11:16:28 AM",
  "id": 1
}]

在这里我可以更新包括标签在内的多个字段。但是我无法更新补丁请求中的标签数组。怎么办?
在发出PATCH请求后,我希望得到的结果应该是这样的。

"tag": ["Prepare", "learn","new task","task2"],
mm9b1k5b

mm9b1k5b1#

将内容类型标头添加到请求中。从https://www.npmjs.com/package/json-server

A POST, PUT or PATCH request should include a Content-Type: application/json header to use the JSON in the request body. Otherwise it will return a 2XX status code, but without changes being made to the data.

相关问题