Error when token is null at decodeToken (Cannot read property 'split' of null)
See original GitHub issueCalling the method isTokenExpired of JwtHelperService I got the following error:
ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'split' of null
TypeError: Cannot read property 'split' of null
at JwtHelperService.webpackJsonp.../../../../@auth0/angular-jwt/src/jwthelper.service.js.JwtHelperService.decodeToken (jwthelper.service.js:62)
at JwtHelperService.webpackJsonp.../../../../@auth0/angular-jwt/src/jwthelper.service.js.JwtHelperService.getTokenExpirationDate (jwthelper.service.js:75)
at JwtHelperService.webpackJsonp.../../../../@auth0/angular-jwt/src/jwthelper.service.js.JwtHelperService.isTokenExpired (jwthelper.service.js:85)
This error occurred because the token obtained in the tokenGetter is null.
One possible solution would be to verify that the token obtained by the tokenGetter is null before attempting to split.
Thanks, Fabio.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:5
Top Results From Across the Web
TypeError: Cannot read Property 'split' of Null in JS | bobbyhadz
The "Cannot read property 'split' of null" error occurs when the split() method is called on a variable that stores a null value....
Read more >TypeError: Cannot read property 'split' of undefined in react error
First thing you can do is to try to console.log(token) to see whether it makes sense. Share.
Read more >Angular 2 + Auth0 "Cannot Read Property 'Picture' Of Null ...
I am getting following error when there is no token available and want to service: TypeError: Cannot read property 'split' of null Angular...
Read more >TypeError: Cannot read properties of undefined (reading 'split ...
I followed tutorial for this code. Is there any problem with const token = req.headers.authorization.split(" ")[1]; ? import jwt, { ...
Read more >express-jwt - npm
This module provides Express middleware for validating JWTs (JSON Web Tokens) through the jsonwebtoken module. The decoded JWT payload is ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve also ran into this when following the readme. There are currently 2 merge requests waiting that could fix this, would appreciate it if one of those could be accepted.
Yeah, I bumped into this yesterday. Had to check the token wasn’t null before passing it in. Agree this would be better dealt with in the isTokenExpired function.