How to decode the JWT encoded token payload on client-side in angular 5?

后端 未结 5 1144
Happy的楠姐
Happy的楠姐 2020-12-23 09:30

I am getting one JWT encoded access token from my API in response. But I am not able to decode it and get it in JSON format. I tried using the angular2-jwt library for it, b

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-23 09:50

    Try and use the JavaScript build in function atob(). Kind of like this:

    atob(token.split('.')[1])
    

    Note: The token is actually a string.

    If you want to know why i split the token here you should check this website jwt.io.

提交回复
热议问题