0👍
If you just want the keys, you can use Object.keys(proxy)
on the proxy.
Converting a proxy to object is done easiest with JSON.parse(JSON.stringify(proxy))
Note also that your action and dispatch are not matching
STORE.dispatch('make_order',{
OrderedPizza: {
pizza: props.pizza,
amount: amount,
size: size_choice
}
})
will pass an object with OrderedPizza
as an item in the object
your action and mutation expect the object passed to be the OrderedPizza
, so the reason you’re not seeing it is that you would technically need console.log(OrderedPizza.OrderedPizza.pizza)
you can fix that either by removing the nested object:
STORE.dispatch('make_order',{
pizza: props.pizza,
amount: amount,
size: size_choice
})
or getting it in the action by destructuring the passed parameter (note the {}
around OrderedPizza: OrderedPizza
)
actions: {
make_order(context, {OrderedPizza: OrderedPizza}){
context.commit('add_pizza_to_order', OrderedPizza)
}
},
Source:stackexchange.com