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

251
Vistas
How to wait for the callback to be finished with fs.readdir?

I'm using fs.readdir callback function to do stuff in a path file but i want to wait for the callback to be finished to continue on with the rest of my code.

const get = async(path_files) => {
    fs.readdir(path_files, function(err, files) {
        do stuff that takes time;
    })
};

When I call this function, I want the console.log to run after the callback of fs.readdir (which is not the case with this code).


const start_get = async() => {
    await get(path_files);
    console.log("the stuff was done");

}

I've seen similars answers on the website but I can't wrap my head around it.

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