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

142
Views
Problema al intentar acceder a datos de vuex

Traté de poner mis datos de agua en Vuex y todo salió bien hasta que intenté acceder a mi matriz de datos.

 const store = new Vuex.Store({ state: { categories: {} }, getters: { categories: (state) => { console.log(state.categories); return state.categories; } }, mutations: { set_categories: (state, data) => { state.categories = data } }, actions: { get_categories: (context) => { axios.get(`${baseUrl}/api/categories?pagination=0`) .then((response) => { context.commit('set_categories', response.data); }); } } });

Aquí está todo el código en vista y así es como accedo a él en el componente de vista

 mounted() { this.$store.dispatch('get_categories'); },
 computed: { stateCategories() { return this.$store.state.categories } },
 console.log(this.stateCategories)

Pero mis datos no aparecen. sabes cual es el problema? Probé con los desarrolladores de herramientas vue y mis datos aparecen en vuex

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

0

Intenta esperar respuesta:

 async mounted() { await this.$store.dispatch('get_categories'); },
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!