How to refetch user in Vuex with Nuxt Auth Module?

我是研究僧i 提交于 2020-07-21 03:49:12

问题


Short Question: Is it possible to update the user data in Vuex manually via the Nuxt Auth Module?

Why do I have that Question: My problem is this. I save some Likes/Follows in MongoDB in the user document. My authentication is realized with Nuxt Auth. Nuxt Auth stores my user document in Vuex on login.

If an user likes something now, it will be stored in the database, but I don't get it into the auth state of Nuxt Auth in Vuex.

An alternative (I thought) would be to change the data in Vuex the same way as in the database. But here I get problems with the "Strict" mode of Vuex.

One possibility that works for me would be to save the user data one more time in a separate state and always update it manually. But do I really have to save the user data several times in Vuex? Doesn't make sense to me.


回答1:


Now I found a solution. It is as simple as:

this.$auth.fetchUser()

but I couldn't find it anywhere in the documentation.

Source: https://nuxt-auth.herokuapp.com/



来源:https://stackoverflow.com/questions/56233773/how-to-refetch-user-in-vuex-with-nuxt-auth-module

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!