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

149
Vistas
Async Delay in sending data

I required all the models and wanted to send all the static data from the database(Mongo) to a single endpoint /getall API. This is the controller file of the route I need to optimise. It's running fine in Postman but there is a delay. Is there any way to fetch the data faster like without using async and await ?

allController.js

const initiative = require("../Models/initiativeModel");
const event = require("../Models/eventSchema");
const collaborator = require("../Models/collaboratorModel");
const speaker = require("../Models/speakerModel");
const chairman = require("../Models/chairmanModel");
const management = require("../Models/ecellHeadsModel");
const faqs = require("../Models/faqModel");
const startup = require("../Models/startupModel");



exports.getAll = async(req, res,next) =>{
    const initiativesPromise = initiative.find();
    const eventsPromise =  event.find()
    const collabPromise =  collaborator.find()
    const speakPromise =  speaker.find()
    const chairPromise =  chairman.find()
    const managePromise =  management.find()
    const faqPromise =  faqs.find()
    const startupsPromise =  startup.find()

    const initiatives = await initiativesPromise.exec()
    const events =      await eventsPromise.exec()
    const collab =      await  collabPromise.exec()
    const speak =       await speakPromise.exec()
    const chair =       await chairPromise.exec()
    const manage =      await managePromise.exec()
    const faq =         await faqPromise.exec()
    const startups =    await startupsPromise.exec()

    return res.status(200).json({
                                        "events": events,
                                        "initiatives": initiatives,
                                        "collaborators": collab,
                                        "speakers": speak,
                                        "chairman": chair,
                                        "management": manage,
                                        "faq": faq,
                                        "startups": startups
    })

> can Promise.all be a faster way than async and await?

    
}
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