laravel-nuxt icon indicating copy to clipboard operation
laravel-nuxt copied to clipboard

User data not saved by store.dispatch

Open karmamaster opened this issue 4 years ago • 1 comments

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 avatar Feb 02 '21 18:02 karmamaster

@karmamaster i use plugins for this case

  1. create auth.js in plugins folder Screen Shot 2564-02-16 at 23 33 24

  2. in nuxt.config.js 1613493263196

  3. can use $auth.user in template or script 1613493904770

  4. result Screen Shot 2564-02-16 at 23 40 41

Screen Shot 2564-02-16 at 23 43 06

maprangsoft avatar Feb 16 '21 16:02 maprangsoft