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

109
Views
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
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!