Answer the question
In order to leave comments, you need to log in
How to pull cart items from localStorage to store in NuxtJs when opening website?
Front part on Nuxt.js api on Laravel
when adding goods to the cart, I first add it to store state.cart and immediately save the cart to LocalStorage
state.cart.push(product)
this.commit('SAVE_CART_TO_LOCALSTORAGE')
SAVE_CART_TO_LOCALSTORAGE (state) {
window.localStorage.setItem('cart', JSON.stringify(state.cart))
},
Answer the question
In order to leave comments, you need to log in
https://www.npmjs.com/package/nuxt-vuex-localstorage
Synchronizes LocalStorage and Vuex
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question