Cannot read property 'store' of undefined
See original GitHub issueHi,
I’m getting an error of TypeError: Cannot read property 'store' of undefined
I’m pretty sure im importing and configuring it right, but here’s a sample of my code:
app.module: import {Ng2Webstorage} from 'ng2-webstorage';
browser module, etc
and then in my service: `import {LocalStorageService} from ‘ng2-webstorage’; @Injectable() export class LoginService {
constructor (private http: Http, private storage:LocalStorageService) {}
private saveTokenId(res: Response) {
let body = res.json();
let success: boolean;
try {
this.storage.store('userId', 'value');
success = true;
} catch(e){
console.log(e)
success = false;
} finally {
return success
}
}`
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Cannot read property 'store' of undefined in Javascript class
Cannot read property 'store' of undefined. I'm clearly missing an import here but unclear as to how I'd import store .
Read more >Cannot read property 'store' of undefined · Issue #137 - GitHub
Hello,. I'm getting the following error at the time of SSR. TypeError: Cannot read property 'store' of undefined at Object.
Read more >I'm getting Cannot read property '$store' of undefined
i'm getting this error TypeError: Cannot read property '$store' of undefined on my component <template> <span @click="requestEmbedManager" ...
Read more >cannot read properties of null (reading 'store') - You.com
To solve the "Cannot read property 'value' of null" error, make sure that the JS script tag is placed at the bottom of...
Read more >How to Read React Errors (fix 'Cannot read property of ...
This error usually means you're trying to use .map on an array, but that array isn't defined yet. That's often because the array...
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
Yes, that was the tricky part 😃. You juste have to use a lambda function and it will works like a charm.
No, that’s just that you pass the this.saveTokenId function directly to map as a callback, so you lose the context. You juste have to keep it by binding the function or wrapping the statement by a lambda fn.
you’re welcome