Angular2 - How to best handle expired authentication token?

前端 未结 5 1277
孤独总比滥情好
孤独总比滥情好 2021-02-05 11:06

I am using Angular 2.1.2.

I have an authentication token (using angular2-jwt) and if it expires my webApi call fails with a 401 error. I am looking for a solution where

5条回答
  •  佛祖请我去吃肉
    2021-02-05 11:30

    Use a browser session:

    https://developer.mozilla.org/de/docs/Web/API/Window/sessionStorage

    Store the data as json string and then recreate form data if request fails.

提交回复
热议问题