如何在 XmlHttpRequest 中使用 Angular 拦截器

vik*_*vik 6 interceptor angular-http angular

我正在使用 Angular 4。还为任何 http 请求使用了 http 拦截器。https://angular.io/api/common/http/HttpInterceptor

但我使用 xmlHttpRequest 的发布请求之一用于某些文件上传事件。标头在 http post 请求(this.http.post(...))中设置正确。但是在 xmlHttpRequest 中,没有调用拦截器。所以不能设置标题。我如何处理 xmlHttpRequest(post 方法)中的 http 拦截器?

Efe*_*Efe -1

拦截器仅适用于 发出的请求HttpClient,为什么它不起作用。即使您可以尝试使用HttpAngular 的旧模块而不是发出请求HttpClient,它也不起作用。