question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when token is null at decodeToken (Cannot read property 'split' of null)

See original GitHub issue

Calling 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:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:5

github_iconTop GitHub Comments

2reactions
Vuurbaardcommented, Jan 27, 2018

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.

1reaction
jculverwellcommented, Aug 16, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found