【问题标题】:Is there a way to inject observe: 'response' from HttpInterceptor in Angular 6?有没有办法从Angular 6中的HttpInterceptor注入观察:“响应”?
【发布时间】:2018-09-29 23:54:43
【问题描述】:

我的应用使用以下 this._http.get("SomeUrl", {observe:"response"}); 接收来自 web api 的自定义标头作为响应 我可以在 HttpInterceptor 中设置标头和参数以进行所有 api 调用并接收带有自定义标头的响应。 我的问题是,是否有一种方法可以在 HttpInterceptor 中为所有 api 调用设置 {observe:"response"},就像我们可以全局设置标头和参数一样? 任何帮助将不胜感激。

【问题讨论】:

    标签: angular angular-http-interceptors


    【解决方案1】:

    {观察:“响应”});必须始终与 http 方法调用一起作为参数。然后可以在 HttpInterceptor 中读取自定义响应头。

    【讨论】:

    • 这有什么具体原因吗。您是否遇到过任何说明这一点的文件。 ?
    猜你喜欢
    • 2018-05-04
    • 1970-01-01
    • 2018-04-11
    • 2017-03-19
    • 2017-04-24
    • 1970-01-01
    • 2017-08-15
    • 2018-06-04
    • 2018-12-29
    相关资源
    最近更新 更多