fetch GET method. Request with GET/HEAD method cannot have body
Data from the server can only be processed by a GET request. I can't use Ajax, because there are problems with the policy.
let sentData = function () {
var requestOptions = {
method: 'GET',
headers: {
'Authentication': 'Token ' + encodeAuth,
'Content-Type': "application/json",
'Access-Control-Allow-Origin': 'LINK'
},
body: 1,
};
fetch("LINK",
requestOptions)
.then(response =>console.log(response))
.then(result => {
console.log(result)
})
.catch(error => console.log('error', error));
}
sentData()
I get the answer file.html:38 error TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body.
If you write a POST, everything works, but the data in the result
= undefined
Where did I make a mistake?
0