Questions tagged angular-http-interceptors

Explore the latest questions and answers asked by our top developers.

How to intercept HTTP calls from the angular web component on the hosting angular application?

I have a need to intercept the HTTP calls inside the web component to append the headers like Authorization token. The headers need to be appended from the parent or hosting application. Not sure if this can be done through the intercepter. Source: Angular Questions

Is it possible to intercept HTTP calls from the Angular element/web component

I have a need to intercept the HTTP calls inside the web component to append the Authorization header. The headers need to be appended to the Http calls happening inside the web component from the parent or hosting application. Source: Angular Questions

Is it possible to intercept HTTP calls from the custom element/web component

I have a need to intercept the HTTP calls inside the web component to append the Authorization header. The headers need to be appended to the Http calls happening inside the web component from the parent or hosting application. Source: Angular Questions

Avoiding infinite loop because of API response in interceptor

I am developing Angular 6 application and there is one usecase in which I am stuck. I have following interceptor code intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { const authReq = req.clone({ withCredentials : true }); if (!window.navigator.onLine) { // if there is no internet, throw a HttpErrorResponse error // since an error is thrown, the […]

Use an Angular Service in an Angular Interceptor

I have a service and I have a http interceptor. I would like to notify my service everytime a intercept happens. This is my code: interceptor.ts: import { Injectable } from ‘@angular/core’; import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from ‘@angular/common/http’; import { Observable } from ‘rxjs’; import { MastermindService } from ‘./mastermind.service’; @Injectable() export […]

Adding the Bearer token to the header doesn’t work as expected

I have created a Spring-Boot back-end along with an Angular front-end in order to try out JJWT, I got the back-end sorted out and I got stuck in the front-end. So basically, I get the token when the login process is finished and then I store it in the localStorage. I created a custom HttpInterceptor […]

By late1
Published
Categorized as angular, angular-http-interceptors Tagged ,

Showing a progress spinner works only the first time / when I reload the page

I wanted to add a progress spinner if the requests are not finished, the class looks like this : @Injectable() export class CustomHttpInterceptor implements HttpInterceptor { public request_count: number = 0 constructor(private app_service: AppService) { } intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { this.request_count++ return next.handle(request).pipe(finalize(() => { this.request_count– if (this.request_count == 0) { this.app_service.loading = […]

By nestea10121
Published
Categorized as angular, angular-http-interceptors Tagged ,

How define a body parameter of a request is FormData or not

I need to append a value (like an id) to all requests of a project, so I add it at the request interceptor. I do not want to lose all other parameters, with this line of code at interceptor: request = request.clone({ body: {…request.body, project: projectId} }); if the parameters are of type FormData I […]

Request stack not sending the new cookie in Angular interceptor

I am trying to create an HttpInterceptor to manage the cookie refresh when the session is expire. The session is renewed successfully but one request in the stack is not sending the new cookie received in login() method. I do not find any way to share the new cookie into the next requests. Here how […]

MSAL acquireTokenSilent with httpInterceptor

I am trying to call the MSAL silentTokenrefresh method from Angular authInterceptor whenever the 401 hits. And then i am trying to recall the failed request again with a new token so the service won’t be interrupted. I have followed this stackoverflow link (answered by Andrei Ostrovski) and implemented the same in my application. There […]

1 13

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq