I am currently working on displaying variables from my backend that update automatically. To achieve this, I am utilizing Vuex store and nuxt.config.js for transferring the variables. API calls are used to modify the variables in the backend. However, I am facing an issue where the data only updates upon page refresh. I display the variables by setting
{{ this.$store.getters.getUserInfo.variable }}
on the frontend page.
I have attempted creating a mapstate computed function and setting the variable in the data()
function, but unfortunately, neither approach has been successful.
Backend API function
exports.getUser = (req, res, next) => {
res.status(200).json({
user: {
username: loadedUser.username,
...
Frontend Vuex store
export const getters = {
getUserInfo(state) {
console.log("State", state)
return state.auth.user;
}
};
Transferring the data with nuxt.config.js
auth: {
strategies: {
local: {
user: {
property: "user",
autoFetch: true
},
...