2

I have a question about HttpClientModule, how can i use it for multiple Authorization, because when use HttpInterceptor Provider, it can only use in one case for example:

  • Api 1 has token A
  • Api 2 has token b

How can i use HttpClient for case above, because it only provide like this:

{ provide: HTTP_INTERCEPTORS, useClass: ApiInterceptor, multi: true }

Hope to have discussion with everyone.

TSL
  • 21
  • 1
  • 2

1 Answers1

1

You can chain multiple interceptors and it will be called in order you specify in providers array of NgModule.

Rahul Singh
  • 19,030
  • 11
  • 64
  • 86
  • yep @Rahul Singh, but i think multiple chain is only one case, you can't use it for multiple case, i can't find documents about how to duplicate httpclient. – TSL Sep 01 '17 at 06:14
  • @TSL why do you want to duplicate the httpclient – Rahul Singh Sep 01 '17 at 06:18
  • because in this case, you interact with your api, and sometime you can interact with youtube or facebook, and you must create each one to add access_token to this. – TSL Sep 01 '17 at 06:26
  • check this if it might help https://stackoverflow.com/a/45987366/2708210 – Rahul Singh Sep 01 '17 at 06:36