I'm using Angular with server-side rendering and TransferState to transfer http data from server to browser. Here is my code:
getProducts() {
let products = this.tstate.get(PRODUCT_KEY, null as any);
if (products) {
return of(products);
}
return this.http.post<any>(config.baseUrl+ 'product', {}).pipe(map(
data => {
this.tstate.set(PRODUCT_KEY, data as any);
return data;
}
))
}
In the first load, I get the data from http request. Then the state is initializing. After that, when the route changes, still transfer state keeps the data, so I can't send the request to get the data. Any idea how to reset transfer state in route changing?