jsonplaceholder
jsonplaceholder copied to clipboard
Response from POST does not match documentation: userId is string instead of integer
Steps to reproduce:
fetch('https://jsonplaceholder.typicode.com/posts', {
method: 'POST',
body: JSON.stringify({
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:
{
id: 101,
title: 'foo',
body: 'bar',
userId: 1
}
Actual response:
{
id: 101,
title: 'foo',
body: 'bar',
userId: '1'
}
I'm not sure which one is correct, but it did make writing tests against it a little confusing 😄
Thanks for maintaining the project, and I'm glad I could help in some way!