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: How to use with Headers? #11

Closed
sanzwebdevelopment opened this issue May 1, 2020 · 2 comments
Closed

Question: How to use with Headers? #11

sanzwebdevelopment opened this issue May 1, 2020 · 2 comments

Comments

@sanzwebdevelopment
Copy link

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[x] Support request
[ ] Other... Please describe:

Current behavior

I currently use a standard request to an API that needs Headers:

return this.http.get<ITideResults>(this.tideServiceURL, { headers: this.headers })

Expected behavior

Expected to be able to continue to use Headers as well as caching :-)

Minimal reproduction of the problem with instructions

Following the docs I tried:

return this.http.get<ITideResults>(this.tideServiceURL, { headers: this.headers }, withCache())

however realise get() expects 2 arguments and not 3. Not sure how to work out where to put withCache() if I'm also using headers.

What is the motivation / use case for changing the behavior?

The API I'm using has usage limits so I'd like to cache the request (for 7 days) on the users device on the first use so as to limit hitting the API ... Cashew seems to be a great option for this use case ;-)

Environment


Angular version: 9.1.0
@ngneat/cashew 1.1.4

Browser:
- [x ] Chrome (desktop) version 80.0.3987.163
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX

For Tooling issues:
- Node version: v12.13.0
- Platform:  Mac
@NetanelBasal
Copy link
Member

this.http.get<ITideResults>(this.tideServiceURL, { ...withCache(), headers: this.headers })

@sanzwebdevelopment
Copy link
Author

Awesome thanks mate :-) Works like a charm and caching perfectly. Love reading your articles ... just starting my Angular journey and learning so much :-)

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