Skip to content

Commit

Permalink
fix: review headers are appended to existing one (open-telemetry#2335)
Browse files Browse the repository at this point in the history
  • Loading branch information
niko-achilles committed Jul 16, 2021
1 parent ae0b276 commit 0532147
Showing 1 changed file with 9 additions and 5 deletions.
Expand Up @@ -56,11 +56,15 @@ export function sendWithXhr(
const xhr = new XMLHttpRequest();
xhr.open('POST', url);

if (!Object.keys(headers).includes('Accept'))
xhr.setRequestHeader('Accept', 'application/json');
if (!Object.keys(headers).includes('Content-Type'))
xhr.setRequestHeader('Content-Type', 'application/json');
Object.entries(headers).forEach(([k, v]) => {
const defaultHeaders = {
'Accept': 'application/json',
'Content-Type': 'application/json',
};

Object.entries({
...defaultHeaders,
...headers,
}).forEach(([k, v]) => {
xhr.setRequestHeader(k, v);
});

Expand Down

0 comments on commit 0532147

Please sign in to comment.