laravel-nuxt
laravel-nuxt copied to clipboard
User data not saved by store.dispatch
I am using a template that require to access to $auth.user info (which saved by auth/fetchUser in login page), but it seems that it is not saved in auth variable by store.dispatch cause it is undefined when i tried to access it by: return this.$auth.user.photo_url
I have double check the api code and it is working well, the json returned and fetched by auth/fetchUser api, the issue here is I user info not save to auth.
I was tried to looking around and they suggested to add property: false
to nuxt.config.js file, but I found that this @cretueusebiu is using custom middleware to check auth user, so there is no auth package to setting it in config file :(.
Anyone help me please!
@karmamaster i use plugins for this case
-
create auth.js in plugins folder
-
in nuxt.config.js
-
can use $auth.user in template or script
-
result