How to use Angular interceptor in XmlHttpRequest
Asked Answered
P

2

8

I am using Angular 4. Also used the http interceptor for any http request. https://angular.io/api/common/http/HttpInterceptor

But I am using one of the post request using xmlHttpRequest for some file upload event. headers are setting properly in http post request (this.http.post(...)). But In xmlHttpRequest, interceptor is not being called. so cannot set the header. How can i handle the http interceptor in xmlHttpRequest(post method)?

Penstock answered 2/4, 2018 at 8:55 Comment(1)
Can you tell me the solution you found for this problem? I am facing the same issueLepidosiren
M
0

Interceptor will work just for request which is made by HttpClient, why that is not working. Even you can try to make request with old Http module from angular instead of HttpClient, also it won't work.

Midvictorian answered 2/4, 2018 at 8:59 Comment(1)
Yes this is the reason of the issue. Any solution for this?Lepidosiren
D
-1

Interceptor transform any request GET/POST/PUT..might be something is missing in code. Can you please share your code so that i can check issue. Also you can refer this blog..given very simple way of Interceptor implementation with example.

Disincline answered 12/3, 2019 at 12:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.