Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Trouble using storage module inside a custom service

$
0
0

@jordan4jc wrote:

For some reason I am having trouble accessing the storage service and setting storage properties with my custom auth service.

I have a login method that should hit my API, get a token, decode the token and store the user information via storage. This all works if I do this in the login promise but that seems like an anti-pattern to me.

I've imported the storage module...

import { Storage } from '@ionic/storage';

And injected into the constructor...

constructor(private http: Http, private storage: Storage) {}

And then when I try to use it in the response from the http service...

...
this.storage.set('profile', this.user);
...

I get the error

Cannot read property 'set' of undefined

I can't seem to find online how it should work within a service differently from within a module.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>