Closed oldmanwerther closed 4 months ago
The extraParams
option is intended only for additional parameters, not headers. Unfortunately there is no option for headers, but you can implement your own HTTP request via eventSource as a function.
Yes, that worked. Thanks. Posting my modified code for anyone else:
eventSources: [
{
events: function (fetchInfo, successCallback, failureCallback) {
fetch(apiEndpointUrl,
{
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
"Access-Control-Allow-Origin": "*"
},
referrerPolicy: "no-referrer",
body: bodyRequest
}).then(res => {
return res.json();
}).then(res => {
successCallback(res);
});
}
}
]
Great!
When configuring to POST into my endpoint, it seems as if I can't add headers as a nested object in extraParams. The rendered payload shows as [object Object].
my js: