I am facing a problem. And the solutions that are accepted by the others, those don't work for me./
I have:
return await fetch(url, { method: httpMethod, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'x-test':'try me', }, body: JSON.stringify(bodyObject) }); But, it seems like no header is set at all.
Cors-header is set, adding mode:'cors' makes no difference.
Am I missing something?
the request:
Accept is empty and Content-Type nor x-test are nowhere to be found.
..
Edit
..
If i need to create new question, do tell me.
So I see that the header is set - thanks to liminal18!-. However, now i want to authorize to an AD.
so now I got:
async callUrl(url, httpMethod, bodyObject) { try { var requestObj = { method: httpMethod, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'x-test':'try me', 'Authorization': 'Basic Uk11bGxlc....' } }; if (bodyObject !== undefined){ requestObj.body = JSON.stringify(bodyObject); } return await fetch(url, requestObj); } catch(error){ console.error(error); } } But still get an 401. I know this is not the clean solution for logging in, but just testing..

