Is there a way to inject observe: 'response' from HttpInterceptor in Angular 6?

淺唱寂寞╮ 提交于 2019-12-13 05:17:06

问题


My app receives a custom header in response from web api using the following this._http.get("SomeUrl", {observe:"response"}); I'm able to set the headers and params in HttpInterceptor to make all api calls and receive the response with custom header. My question is if there is a way to set {observe:"response"} in HttpInterceptor for all the api calls just like we can set headers and parameters globally? Any help would be appreciated.


回答1:


{observe:"response"}); has to be always along with the http method call as an argument. Custom response header then could be read in HttpInterceptor.



来源:https://stackoverflow.com/questions/52448703/is-there-a-way-to-inject-observe-response-from-httpinterceptor-in-angular-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!