I have a get fetch request with header having Bearer token, getting 401 unauthorized error, even if the response status condition checked in the then statement,the browser is showing sign in alert box, can you please suggest how to avoid browser alert on 401 error
function call(url: string, req:RequestInit):Promise<Any>{[enter image description here][1]
req.headers = { Authorization: 'Bearer ' + idToken };
return fetch(url, req)
.then((response: Any) => {
if (response.status !== 200) {
// return to base url
return false;
} else {
return response;
}
})
}
for