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.

Cannot make http requests when token is not present.

See original GitHub issue

I am getting following error when there is no token available and want to request server using HttpClient service:

TypeError: Cannot read property 'split' of null

Angular v4.3.1 angular-jwt v1.0.0-beta.2

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
coskuntekincommented, Jul 25, 2017

This is config. Maybe we can add on readme.

import { JwtModule } from '@auth0/angular-jwt';
import { HttpClientModule } from '@angular/common/http';

Get token

export function getToken() {
  return localStorage.getItem('currentUser');
}

Import Jwt Module

    JwtModule.forRoot({
      config: {
        throwNoTokenError: false,
        tokenGetter: getToken,
        whitelistedDomains: ['localhost:4567']
      }
    }),
1reaction
coskuntekincommented, Jul 25, 2017

@chenkie would you update also readme? Seems like this line no longer work.

JwtModule.forRoot({
      config: {
        tokenGetter: () => {
          return localStorage.getItem('access_token');
        },
        whitelistedDomains: ['localhost:3001']
      }
    })
Read more comments on GitHub >

github_iconTop Results From Across the Web

Axios Request Does Not Return a Token - Stack Overflow
So i tried to console.log the result of the request, and cannot find any token there inside the object array. Object { "config":...
Read more >
Resolve API Gateway REST API 403 “Missing Authentication ...
When I try to invoke my Amazon API Gateway REST API, I get 403 "Missing Authentication Token" error messages. How do I troubleshoot...
Read more >
Access Token Response - OAuth 2.0 Simplified
If the request for an access token is valid, the authorization server needs to generate an access token (and optional refresh token) and...
Read more >
Single-page application: Acquire a token to call an API
If no access token is found or the access token found has expired, it attempts to use its refresh token to get a...
Read more >
Refresh Token - Constant Contact Community - 332029
There are at least two scenarios I can see where this can break down - 1) error occurs after receiving the updated tokens...
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