question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TransferHttpCacheModule not taking request params into account

See original GitHub issue

There 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:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
CaerusKarucommented, Mar 7, 2022

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.

1reaction
dottodotcommented, Mar 11, 2018

Is there any reason why req.urlWithParams couldn’t be used rather than req.url

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found