Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

347
Views
Vuex Data doesn't get updated on fetch when reloading browser (SSR) Nuxt

I found something about this bug I explained at end;

Component codes

  async fetch(){ await this.$store.dispatch('bots/getBots') },
  computed: { ...mapState('bots', ['bots']) },

Store codes

export const state = () => {
  return {
    bots: []
  }
}

export const mutations = {
  UPDATE_BOTS(state, bots) {
    state.bots = bots
  }
}

export const actions = {
  getBots({commit}) {
    this.$axios.$get('url', {headers: {uid: '12345'}})
      .then(res => {
        commit('UPDATE_BOTS',res.robots)
      })
      .catch(e => {
        console.log(e)
      })
  }
}

Issue: When moving between pages via nuxt-link data loads perfectly but when I reload the page bots state is empty...

Found Issue: I use nuxt-auth and I had one plugin for checking status of axios request that if it was 401 unauthorized I logout user if he was loggedIn, So status undefined error was from here but I commented the plugin codes and I got other error from nuxt-auth that causes that problem I had So I related that issue in other question u can see it here: Nuxt-Auth Bug: Looks for autherization in any get request that has headers config

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

It is the expected behavior. Vuex state is kept in memory and when you reload the page it gets purged.

about 4 years ago · Juan Pablo Isaza Report

0

Instead of this state

export const state = () => {
  return {
    bots: []
  }
}

try this

export const state = () => ({
    bots: []
})
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!