Seeking assistance in loading products from my pinia store upon the initial load of my Vue app.
Check out my app.js below:
import {createApp} from "vue";
import App from "./App.vue";
import router from "./Router/index";
import { createPinia } from "pinia";
createApp(App)
.use(router)
.use(createPinia())
.mount("#app")
Here is the snippet of my store:
import { defineStore } from "pinia";
import axios from "axios";
const state = {
cart: [],
order: {},
customer: {},
loading: true,
error: null,
products: [],
};
export const useCartStore = defineStore("shopState", {
state: () => state,
actions: {...},
getters: {...},
persist: true,
});
I'm looking to trigger the getProducts
function when the app initializes. This was manageable with Vue2, but I'm uncertain about how to achieve this with the new composition API version of Vue. Any advice or suggestions on how I can accomplish this would be greatly appreciated. Thank you!