Hello,
I’m trying to retrieve and store a JWT token that is sent back to me from a server in the Authorization header. Here is my code:
fetch ( MYURL , {
“method” : “post” ,
“headers” : {
“Content-Type” : “application/json”
},
“body” : JSON . stringify ( userData )
})
. then (( httpResponse ) => {
if ( httpResponse . ok ) {
console . log ( httpResponse . headers )
return httpResponse . json ();
} else {
return Promise . reject ( “Fetch did not succeed” );
}
}). then (( json )=> {
console . log ( json )
})
. catch ( err => console . log ( err ));
Yet in the console.log(httpResponse.headers) it just logs and empty object. When viewing the request/response in dev tools I see the Authorization header:
What am I doing wrong?