PUT request without stringify'ing body returns 500
BrennanAyers opened this issue · 0 comments
BrennanAyers commented
Steps to reproduce:
- Note the lack of stringifying the body object
fetch('https://jsonplaceholder.typicode.com/posts/1', {
method: 'PUT',
body: {
id: 1,
title: 'foo',
body: 'bar',
userId: 1
},
headers: {
"Content-type": "application/json; charset=UTF-8"
}
})
.then(response => response.json())
.then(json => console.log(json))
Expected response:
400 Bad Request
Actual response:
500 Internal Server Error
I believe it has something to do with the mismatch in the Content-Type
and the input. If the Content-Type
header is set to application/x-www-form-urlencoded
, the response will return a 200, but with the following body:
{
"[object Object]": "",
"id": 1
}