JSFiddle - React, Tailwind, and code Playground
JavaScript
// Code goes here
function createRequest(type, url, payload) {
const options = { headers: {
"Content-Type": "application/json",
"x-request-id": '...',
"x-sender-id": "mysender"
},
method: 'POST',
body: JSON.stringify(payload),
mode: 'no-cors',
cache: 'no-cache'
};
return new Request(url, options);
}
// -----------------------------
// a simple test
const request = createRequest('post', '/check', {test: 'where are my headers?'});
console.log(request);