3๐
โ
When I just do console.log(JSON.parse(this.$store.state.user)); I get the object and I can see the properties.
This means that this.$store.state.user
contains JSON string which describes the user
object.
Thus JSON.parse(this.$store.state.user.userId)
is incorrect. In this case you are trying to get property userId
from string, getting undefined
and JSON.parse
function fails on the first symbol, which is 'u'
.
You should use JSON.parse(this.$store.state.user).userId
instead.
๐คSergey Mell
Source:stackexchange.com