Closed sanzwebdevelopment closed 4 years ago
this.http.get<ITideResults>(this.tideServiceURL, { ...withCache(), headers: this.headers })
Awesome thanks mate :-) Works like a charm and caching perfectly. Love reading your articles ... just starting my Angular journey and learning so much :-)
I'm submitting a...
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