Error with associative array
Closed this issue · 2 comments
florianmarical commented
Hello
I have a problem when save one data object with an associative array in property .
exemple 1 WORK :
let values = [1, 2, 3]
const product = {
name : 'test',
values = values
}
state.list.push(product)
this.$wbc_cookiz.set("card", state.list)
state.list = this.$wbc_cookiz.get("card")
console.log(state.list)
the First console.log and the Second console.log display:
0: {
name: "test"
values: (3) [0:1, 1:2, 2:3]
}
exemple 2 DON'T WORK :
let values = []
values['v1'] = 1
values['v2'] = 2
values['v3'] = 3
const product = {
name: 'test',
values: values
}
state.list.push(product)
console.log(state.list);
this.$wbc_cookiz.set("card", state.list)
state.list = this.$wbc_cookiz.get("card")
console.log(state.list);
the first console.log display:
0: {
name: "test"
values: (3) [v1:1, v2:2, v3:3]
}
the second console.log display:
0: {
name: "test"
values: (0) [ ]
}
The array is empty. I don't understand why.
I use cookie-universal with nuxt in monde SSR. The call to $wbc_cookiz.set("card", state.list) and $wbc_cookiz.get("card") is in the vuex.
Have a good day
regards
florianmarical commented
It's my bas sorry
Not use array but object:
let values= {}
values.v1 = 1
values.v2 = 2
Sorry
Have a good day
microcipcip commented
Yes, I was going to write that solution, have a good day as well :)