Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
356 views
in Technique[技术] by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...