async function postData(url = '', data = {}) {
const response = await fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
"X-Auth-Token": 'abc'
},
body: JSON.stringify(data)
});
console.log(response.json());
}
postData('url', { answer: 42 });
Error: Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body. at postData (index.js:3:28) at index.js:14:1