I am trying to access the api but for accessing the api I need token so When I try to hit the api it redirects to the auth page.
I can see the redirection is happening in the network tab.
is there any way to prevent this?
I wanted to get the 302 error code when I first hit the api(its giving 302 but with fetch/Redirect) but because of automatic redirection its throwing error and going to error block always.
fetch(url, { method: 'POST', redirect: 'error'})
.then(response => {
// handle 302 response
})
.catch(function(err) {
console.info(err);
});
Edit: To get the token I need to redirect user to the auth page. so once I get the 302 error Ill redirect the user to the auth page.