All the values stored in localStorage are undefined
See original GitHub issueI am getting back the access tokens and everything back right from Devise Auth Token right, but when storing those into the localStorage, it is storing undefined
and hence every other verifyToken
is failing.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Why is localStorage["..."] undefined, but localStorage.getItem ...
In javascript you always get an undefined value for keys that does not exist inside an object. a = {}; //new object alert(a["test"]);...
Read more >localStorage returning undefined - Hashnode
When setting (saving) objects in the localStorage, the API will always return undefined - you are doing everything all right. Also, it can...
Read more >Why does localStorage.getItem() return undefined? - Reddit
getItem() return undefined? Everything I'm reading says localStorage is synchronous. And there's no promise returned.
Read more >Storage.setItem() - Web APIs - MDN Web Docs
A string containing the value you want to give the key you are creating/updating. Return value. None ( undefined ). Exceptions. setItem() ...
Read more >Local Storage
The localStorage object provides a key-value database — think JavaScript object, which maps keys (a.k.a. fields, property names) to values — for use...
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 FreeTop 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
Top GitHub Comments
@AmitJoki
BOOM. I figured out what was going on after debugging and trying to write my own handler…
In my app’s configuration, the headers were not being exposed.
This is pretty critical; @kylecorbelli I might recommend adding some notes to the README (or I can open a quick PR), it was something really confusing and easy to miss.
I’m using
Rack::Cors
:The important configuration here is this:
:expose => ['uid', 'client', 'expiry', 'access-token', 'token-type']
Without this, the headers aren’t actually provided to the Client in the Response; though they’re visible in developer tools and such, the browser can’t access them.
Once I added this to my Rails app, everything worked like a breeze.
Hope this helps!
I haven’t gotten exactly to the bottom of the issue, but switching over to a fork of this, by joshuadev fixed my problem. Try installing hs fork of the npm package.
Sent from my Redmi 4 On Peter Lawless notifications@github.com, 8 May 2018 10:02 pm wrote:
Still having this issue, even with the rack-cors configuration. After confirming my account via email, I am redirected to the success url and I can see access-token, client, client_id, token, expiry, etc, all in the query string parameters. But when the client kicks off a request to verify the token, all the parameters are undefined and the request returns a 401. It may also be worth noting that my client and server reside on the same domain? Please help.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/kylecorbelli/redux-token-auth/issues/39#issuecomment-387463188, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AE62mhMikVTe03GbCv8HMmwWsjG3FOKEks5twciwgaJpZM4Tz3de.