Answer the question
In order to leave comments, you need to log in
How to get response cookies in Angular interceptor?
Hello! Can you please tell me how to get the response cookies in the Angular interceptor? I write code like this
import {Injectable} from '@angular/core';
import {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse} from '@angular/common/http';
import {Observable} from 'rxjs';
import {tap} from 'rxjs/operators';
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
constructor() {}
intercept(
req: HttpRequest<any>,
next: HttpHandler
): Observable<HttpEvent<any>> {
const authReq = req.clone({
headers: req.headers.set('sess', '0')
});
return next.handle(authReq).pipe(
tap(
event => {
if (event instanceof HttpResponse) {
console.log(event.headers);
}
}
)
);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question