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

344
Views
How do you execute code once data from an http request is received?

I'm new to web development and have been using a node.js web server running express as a backend for an app I'm working on for my school. One of the things this server needs to do is to query the school's database, receive information, and return that to the user. While I've gotten it to work, I'm receiving a delay of almost 2 seconds from the start to the end of the request. This is because the server must make 2 requests to get the information it needs. What I'm trying to figure out is how to make both of them run asynchronously and preforming tasks once the information is received. Attached is some demo code showing what I've got so far.

   axios
        .get(
            `https://schoolserver.com/classes`,
            config
        )
        .then((res) => {
            classes = res.data.value;
            axios
                .get(
                    `https://schoolserver.com/meetings`,
                    config
                )
                .then((res) => {
                    meetings = res.data.value;
                    }
                    response.send(classes, meetings);
                })
                .catch((err) => {
                    console.log(err);
                });
        })
        .catch((err) => {
            console.log(err);
        });

As you can see I have 2 axios requests nested within each other which creates unwanted delay. I want a solution where both requests are done independently and then code is executed once the data is received. If there are any solutions please reach out.

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!