Ajility
Handling API Requests on pages from Client / Server Side (SSR)
basically a customer can view different products during a session on my website.. as they navigate around, I keep information in the store cached incase they navigate to a product they've already viewed, they've already got that info loaded
34 replies
Handling API Requests on pages from Client / Server Side (SSR)
You will notice that I am tracking if the request is originated from Server Side or Client side using an argument that is passed to
setProductData()
.. my pinia CatalogStore.fetchProductBySlug
action looks like this:
I check if params.is_server_side
is true
. If It is, I use useAsyncQuery
, else useApolloClient()
. This is wordy and doesn't seem right.. how should I be approaching this type of issue? I think I'm missing something fundamental..34 replies
Differentiating SSR from Client side requests with Pinia...
Is this something I can safely ignore? If not, how can I resolve it without writing duplicate code and while still using pinia store to cache results on the front-end, as the user navigates thru pages on the SPA? I am new to SSR. The docs indicate that its not recommended, but do not indicate why...
9 replies