简体   繁体   中英

Fetch API Delete Request Data Returns - null

I'm trying to send a Delete request using Fetch. I get a response status - OK, but data is null. However the request has a body with an object, but I'm unable to see it back in the data received from the request. Here is a sample code.

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)
    })

From my limited understanding of "fetch", you seem to looking at the response data, not the request data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM