I am sending (rather rying to) send a GET request to my server using the native JavaScript fetch API with an HTML client. On postman I can do this, no problems, what is wrong?
Here is the error:
Unhandled Promise Rejection: TypeError: Request has method 'GET' and cannot have a body
Again, I need to make a GET request, not a post request... Postman does allow this.
Here is the code:
fetch('http://www.localhost:3000/get-data', {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
a: 1,
story: document.getElementsByTagName("input")[0].value,
})
});
PD: I using Safari, bur Chrome, although marking a different looking error that conveys the same message, still does not work.