Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: use saveItem with loadFromObservable? #30

Closed
boye opened this issue May 17, 2017 · 3 comments
Closed

Question: use saveItem with loadFromObservable? #30

boye opened this issue May 17, 2017 · 3 comments

Comments

@boye
Copy link

boye commented May 17, 2017

Perhaps I have overlooked something in de docs, but I am wondering if I need to use saveItem first before I call loadFromObservable? My plan is to integrate ionic-cache into my generic Api provider that handles all HTTP traffic. I have something similar to the loadList example:

request(method: string, endpoint: string, body: any, options?: RequestOptions): Observable<any> {
    // Some other code
    ...
    const apiCall = this.http.get(url, options);
    const key = `prefix:${endpoint}`;
    return this.cache.loadFromObservable(key, apiCall.map(res => res.json()));
  }

However, using it like this results in a Runtime Error saying "No such key". Therefore I thought I might be calling saveItem first? Can you perhaps point me in the right direction?

Many thanks!

@Nodonisko
Copy link
Owner

Sorry for late response. No it's not needed, this looks like a bug. Did you got this exception everytime or only sometimes?

@Nodonisko
Copy link
Owner

Did you installed @ionic/storage?

@boye
Copy link
Author

boye commented May 31, 2017

I worked around it by calling loadFromDelayedObservable instead of loadFromObservable . Thanks for replying though :)

@boye boye closed this as completed May 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants