Fix authorization header when no access token

This commit is contained in:
Fosco Marotto 2021-02-09 11:16:04 -05:00
parent 31922ea58b
commit ae036995bf
1 changed files with 6 additions and 5 deletions

View File

@ -40,12 +40,13 @@ const notify = options =>
const fetchFromApi = (path, method, accessToken) => { const fetchFromApi = (path, method, accessToken) => {
const url = (new URL(path, self.location)).href; const url = (new URL(path, self.location)).href;
return fetch(url, { let headers = {
headers: {
'Authorization': `Bearer ${accessToken}`, 'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, }
if (!accessToken) { delete headers['Authorization'] }
return fetch(url, {
headers: headers,
method: method, method: method,
credentials: 'include', credentials: 'include',
}).then(res => { }).then(res => {