TransferHttpCacheModule not taking request params into account
See original GitHub issueThere seems to be an issue with TransferHttpCacheModule
sending the previous request to the server. When I navigating to and from different product categories I will some get the wrong response returned i.e I’ll get results for the last category I visited rather than the one it supposed to return.
I can see the value from route.paramMap
is changing but the server is not receiving that value it get the last value.
So I’m believe it because the cache isn’t taking the change in params into account and assume it’s the same request
export class ShopListResolver implements Resolve<any> {
constructor(private service: ApiService, private router: Router) {
service.endpoint = 'productdisplay';
}
resolve(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
): Observable<any> {
const category = route.paramMap.get('category');
return this.service
.find({
$category: category,
published: true,
$sort: ['weight'],
$select: ['title', 'listing_image', 'product_type', 'slug']
})
.pipe(take(1));
}
}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Angular Transfer State not preventing repeat http calls
TransferHttpCacheModule installs a Http interceptor that avoids duplicate HttpClient requests on the client, for requests that were already ...
Read more >The newline Guide to Angular Universal - Part 3
ProductListComponent retrieves a list of products using ProductsService . ProductsService sends an HTTP request to retrieve the list of ...
Read more >How to transfer the Angular server-side state to the client-side
Solution is in the TransferHttpCacheModule. TransferHttpCacheModule installs a Http interceptor that avoids duplicate HttpClient requests on the ...
Read more >Bringing SEO to Angular Applications | by Andres Rutnik
They will click on your anchors, but they are not going to ... and reacting to its changes in path and query parameters...
Read more >Angular Projects Second Edition
should take into account all sorts of network types. ... An Angular developer does not need to remember how to create components, modules,....
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 Free
Top 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
I understand the merit for a GraphQL-like functionality. Unfortunately we cannot build this functionality for everyone just to satisfy GraphQL users. My recommendation is to implement your own interceptor based on the code in this library, with special accommodations for GraphQL.
Is there any reason why
req.urlWithParams
couldn’t be used rather thanreq.url