Interceptors in Angular2

后端 未结 3 774
说谎
说谎 2020-12-15 07:32

I am trying to build a demo app on Angular2.beta.0 which would have login mechanism and then all the other API calls would have the acquired session token s

3条回答
  •  春和景丽
    2020-12-15 07:48

    There's an example of how to do this for intercepting 401 responses from authenticated APIs here.

    http://www.annalytics.co.uk/angular2/javascript/typescript/ionic2/2017/02/26/Angular2-Http-Auth-Interceptor/

    The post above shows how to add a standard Authorzation header to all outgoing HTTP requests and also automatically refresh any JWT like token.

提交回复
热议问题