Questions tagged [angular-httpclient-interceptors]

33 questions
28
votes
3 answers

Use a promise in Angular HttpClient Interceptor

Can I use promise within HttpInterceptor? For example: export class AuthInterceptor implements HttpInterceptor{ this.someService.someFunction() .then((data)=>{ //do something with data and then return next.handle(req); …
5
votes
0 answers

Error when testing HttpInterceptor Angular 10

I'm working on an Angular 10 application that uses an HttpInterceptor for adding a specific header to all responses. Unfortunately, when trying to test this interceptor, I keep getting the following error: Error: Expected one matching request for…
4
votes
1 answer

HttpInterceptor after rxjs pipeable operators

is it possible to intercept a HttpClient get request after the execution of some pipeable operators of rxjs. In my case, I have an auto-generated http service which transforms the blob responses to objects. My global error interceptor needs to…
3
votes
2 answers

Interceptor not intercepting, despite only one HttpClientModule

I have application in Angular and I have only one HttpClientModule, but when I provide HttpClient in constructor like this: export class UserService { constructor(private http: HttpClient /** <---- this one is ok, and requests are intercepted */)…
Viszman
  • 1,378
  • 1
  • 17
  • 47
3
votes
1 answer

How to add interceptors to app.module conditionally?

I read other topics but none of them reflects my problem. Background first - we got an Angular App which works in two modes - in first mode applications uses one API and in the second one - another one. This, what I want to achieve is to have Http…
3
votes
1 answer

Angular - Is there a way to defer service instantiation until app is asynchronously initialized?

I have an Angular 5 application with an HTTP interceptor that calls another service whenever it intercepts a request. I want to make the service configurable using a config file, so I tried using a service that loads the configuration asynchronously…
Oram
  • 1,589
  • 2
  • 16
  • 22
3
votes
0 answers

Intercept incoming HTTP request

I am working on application which uses SSO for authentication. Our Angular 5 application is deployed on IIS server. So whenever user enters URL we are redirecting them to SSO login page from IIS server, then they will authenticate themselves and be…
2
votes
1 answer

How to delete muliple httpparams in angular

I'm adding custom params for API's for some use case which is not require to send it BE and I want to delete them before sending to BE. Url: https://www.dummy.com?reload=true params: req.params.delete('reload') Deleting 1 param (reload) working…
2
votes
1 answer

Read the response header when the status is 302 in Angular

How can I read the response header of XHR call by $http in Angular (v8+) as its status is 302 and it is redirected by browser? In my case as the redirect url has a different origin, I only get an Unknown error from the code below: return…
2
votes
3 answers

Can't inject Router into HttpInterceptor (Angular 7)

I want to inject the Angular Router into my HttpInterceptor. Unfortunately, the following error is thrown in the browser console: TypeError: this.router is undefined I've added this to my constructor as usual: constructor (private router: Router)…
2
votes
1 answer

Can get upload progress event in HttpInterceptor but not from HttpClient call?

I am using HttpInterceptor and I have an Http service that calls http methods running HttpClient. I am trying to get the progress of the upload and I am facing two issues here, First, progress event is only being caught by HttpInterceptor and not…
2
votes
2 answers

Angular 6 interceptor : Change response content type

I'm using a REST api, that send me json data with file info (base64 content, mime...). I want to open PDF in Chrome. URL.createObjectURL is a bad solution because after redirection, we can't download the file. So, as a backend, i want to change the…
2
votes
1 answer

Angular 5 - Manipulating HttpErrorResponse's error property in HttpInterceptor

I have custom error message body as JSON from rest api. { "status":400, "url":"/api/abc", "message":"Custom Error Message" } I want to get it as object in subscribe's error scope. I tried to convert it to an object after every response…
Ali Kurnaz
  • 57
  • 8
2
votes
0 answers

Get httpclient request query parameters

Hi I am using an Angular 5 interceptor to check if the HttpClient request URL contains query params but it always comes back false even though in Network I see the query param being passed. import { HttpEvent, HttpInterceptor, HttpHandler,…
1
vote
1 answer

LoaderService issue using MSAL Service for login in Angular

I'm developing an Angular app that requires MS credentials for get logged in. Furthermore I'm using an Http Interceptor for showing up a loader component when any HttpClient's call is in use. My problem here is when I log into my app, the calls that…
1
2 3