Handling 401s globally with Angular

后端 未结 8 931
误落风尘
误落风尘 2020-11-28 18:50

In my Angular 2 project I make API calls from services that return an Observable. The calling code then subscribes to this observable. For example:

getCampai         


        
8条回答
  •  有刺的猬
    2020-11-28 19:29

    From Angular >= 2.3.0 you can override the HTTP module and inject your services. Before version 2.3.0, you couldn't use your injected services due to a core bug.

    I've created a gist to show how it's done.

提交回复
热议问题