I'm very much new to Vue so please excuse my lack of knowledge here.
In one of my (child) components
(Product_Collection.vue)I make an axios request to get some products from my Shopify store via their GraphQL API:data: () => { return { products: null } }, methods: { getProducts: function(){ // 1. axios code here... // 2. ...then assign result to "this.products" data property } }The products are displayed as thumbnails (let's say there's 10 t-shirts). I then click a product to view it in more detail with more product info and images etc (very much an Amazon-like experience).
The product is shown on it's own in a
Product_Single.vuecomponent. So far so good.
But here's the problem...
- When I click back to the products page
(Product_Collection.vue)(the page with the 10 t-shirts on) the axios request to the Shopify API gets called again and the component is re-rendered from scratch.
My question is how do I tell Vue to stop fetching the data from the Shopify API each time the component is rendered? Thank you