angular-2-local-storage icon indicating copy to clipboard operation
angular-2-local-storage copied to clipboard

get() method doesn't return string values which are not enclosed in quotes (")

Open hesperius1 opened this issue 8 years ago • 1 comments

3rd party libraries may access localStorage through window object which saves strings (e.g. authentication tokens by angular2-jwt) without quotes, e.g. (abcd...)

  • get() method parses stored values as JSON and requires all strings to be enclosed in quotes ("abcd...") and returns null otherwise.

as the result - there is no way to access saved data.

hesperius1 avatar Jan 05 '17 05:01 hesperius1

Please try this way.

let currentUser = JSON.parse(this.localStorageService.get('TOKEN').toString());

webcat12345 avatar Apr 25 '17 10:04 webcat12345