Как получить данные из productName?
comp.vue:
export default {
data() {
return {
productName: this.$store.state.products
}
store.js
export default {
state: {
products: [],
productName: []
},
mutations: {
LOAD_ALL_PRODUCTS(state, payload) {
state.products = payload
}
},
actions: {
async loadAllProducts({commit}) {
try {
let res = await Vue.axios.get('/products/')
commit('LOAD_ALL_PRODUCTS', res.data)
} catch(err) {
console.log(err)
}
}
},
getters: {
getProducts: state => state.products,
mounted() {
console.log(this.productName);