Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

110
Vistas
Vue.js issue calling fetch from a fetch async issue
 async created() {
    if (this.tournamentId === 0) await router.push('/');
    this.events = await this.fetchEvents(this.tournamentId);
    this.setRings(this.events);
  },
  methods: {
    async fetchEvents(tournamentId){
      const res = await fetch(httpserver + `all-events.php?tid=${tournamentId}`)
      const data = await res.json();
      return data
    },
    setRings(events){
      events.forEach(e => {
          e.rings = this.fetchRings(e.EventID);
      })
    },
    async fetchRings(eventId){
      const res = await fetch(httpserver + `pool-information.php?eid=${eventId}`)
      let data = await res.json();
      return data;
    }
 }

For each tournament, I need to make another call to get the pools. This however doesn't work very well, it seems making the methods async doesn't really cause vue to wait until until it's done loading before trying to move on.

I start with an error like this... Events.vue?aa9c:51 Uncaught (in promise) TypeError: events.forEach is not a function

The page will load, but it rarely will display any of the data, because it will render before the data is done loading.

How can I chain up two fetchs in a way that the render won't happen until after the data has been fetched?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda