Reputation: 3317
I made API server with DRF so if delete the data, I have to use DELETE method.
So I tried to request to server with method: 'DELETE', But it doesn't work.
[js file]
fetch("http://abc/article/24",
{
method: "DELETE",
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
},
body: JSON.stringify({password: '123'})
})
I captured packet with Chrome Network tab, It's Request Header is OPTION.
In my code, I defined method to DELETE. But why Request Header's METHOD is OPTION?
[ADDED SCREENSHOT]
I set the response code if success, return 204, fail return 304
Upvotes: 5
Views: 13307
Reputation: 3317
Solved by Content-Type: 'application/json'
and payload into http body.
That works perfectly.
Upvotes: 4