I am trying to check for specific response headers in my angular app. If user attempts to access a route that requires a valid JWT, with an expired JWT, the response header from the back-end ASP.NET Core server has token-expired: true. I would like to check for that value before sending the user to the refresh route.
I have tried the following to be able to view the entire response header but I have been unsuccessful:
`public fetchPosts(): Observable<HttpResponse<Object>> {
var b = this.http.get<HttpResponse<Object>>('api/v1/posts', {observe: 'response'}).pipe(
tap(resp => console.log('THE RESPONSE FOR FETCH POSTS IS:', resp))
)
console.log('THIS IS VALUE OF B: ', b);
return b;
}`
The value of b is always this :
`
Observable {_isScalar: false, source: Observable, operator: DoOperator}
post.service.ts:20
_isScalar:false
operator:DoOperator {nextOrObserver: , error: undefined, complete: undefined}
complete:undefined
error:undefined
nextOrObserver:function (resp) { … }
[[FunctionLocation]]:internal#location
[[Scopes]]:Scopes[2]
arguments:TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
caller:TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
length:1
name:""
prototype:Object {constructor: }
`
I understand that I will need to specifically expose certain response headers on my back-end server, but the fact that the b object has the error and complete keys of both undefined, makes me wonder if I am actually doing something wrong?
Any insight would be greatly appreciated.