Looking to decode a token, but proceeding with caution.
npm install jwt-decode --save
In my component.ts file:
import * as jwt_decode from 'jwt-decode';
.
.
.
console.log("Yes");
localStorage.setItem('token', res.token);
this.flagProgressBar = false;
console.log('res.token: ');
console.log(res.token);
console.log('localStorage token:');
console.log(localStorage.getItem('token'));
const tokene = res.token;
const decoded = jwt_decode(tokene);
console.log(tokene);
console.log(decoded);
Console output:
Yes
res.token:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoRW1hcy5taWNyb3NvZnQuY29tL3dzLzIwMgvMDYvaWRlbnRpdHkvY2xhaW1zL3JvbGUiOiJGdWxsQWRtaW4iLCJleHAiOjE2MDM5MjEzNzMsImlzcyI6Imh0dHBzOi8vbG9jYWxob3N0OjQ0MzU0In0.-e7cYAgQQVTcHlPrw1sWn6IsjhVPfjlItx9XGIn3S9w
localStorage token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoEW1hcy5WNyNTaWNyb3NvZnQuY-29tL3dzLzIwMDgvMDYvaWRlbnRpdHkvY2xhaW1zL3JvbGUiOiJGdWxsQWRtaW4iLCJleHAiOjE2MDM5MjEzNzMsImlzcyI6Imh0dHBzOi8throughlyResolved42tWax&joinserePowerPathProgram=pass--RegressionOfALodieCatergologicalasjaskedAwskesffo.-Ahdboxscorsoriiterirbiwe.
ERROR: TypeError - jwt_decode__WEBPACK_IMPORTED_MODULE_2__ is not recognized as a function
at SafeSubscriber.Service.postDataLogin.subscribe.flagProgressBar [as _next]
Can you pinpoint where the issue lies?