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

346
Vistas
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
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