获取 API 删除请求数据返回 - 空

问题描述

我正在尝试使用 Fetch 发送删除请求。我得到一个响应状态 - 好的,但数据为空。然而,该请求有一个带有对象的主体,但我无法在从请求接收到的数据中看到它。这是一个示例代码

let myObj = {
    test: test1
}

fetch(deleteUrl,{
        method: 'DELETE',headers: {
            "Content-type": "application/json;charset=UTF-8"
        },body: JSON.stringify(myObj)
    }).then(
        response => response.json()
    ).then(function(data) {
        console.log(data) // Here the data is always null,but I want to log the request body(myObj)
    })

解决方法

根据我对“获取”的有限理解,您似乎在查看响应数据,而不是请求数据。