How to extend angular 2 http class in Angular 2 final

前端 未结 6 1208
别跟我提以往
别跟我提以往 2020-12-09 03:39

I\'m trying to extent angular 2 http class to be able to handle global errors and set up headers for my secureHttp service. I found some solutions but it doesn\'t work with

6条回答
  •  [愿得一人]
    2020-12-09 04:13

    You can check https://www.illucit.com/blog/2016/03/angular2-http-authentication-interceptor/ which will help you.

    Change your providers as below for latest release and check it :

    providers: [
      {
        provide: SecureHttpService,
        useFactory: (backend: XHRBackend, defaultOptions: RequestOptions) => {
          return new SecureHttpService(backend, defaultOptions);
        },
        deps: [ XHRBackend, RequestOptions]
      },
      Title
    ]
    

提交回复
热议问题