I just noticed that the Header Object that was possible to use in the previous HTTP RequestsOption is not anymore supported in the new Interceptor.
It\'s the new Int
Angular 4.3+
Set multi headers in Interceptor:
import {
HttpEvent,
HttpInterceptor,
HttpHandler,
HttpRequest,
HttpHeaders
} from '@angular/common/http';
import {Observable} from 'rxjs/Observable';
import {environment} from '../../../../environments/environment';
export class SetHeaderInterceptor implements HttpInterceptor {
intercept(req: HttpRequest, next: HttpHandler): Observable> {
const headers = new HttpHeaders({
'Authorization': 'token 123',
'WEB-API-key': environment.webApiKey,
'Content-Type': 'application/json'
});
const cloneReq = req.clone({headers});
return next.handle(cloneReq);
}
}