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

326
Vistas
Using inquirer js inside a loop is not waiting for user input

I have an array of changes to apply to the database and for every change I need user confirmation. Therefore I'm using inquirer js to ask the user if he wants to apply those changes.

I tried outside the loop and works but if I do it inside the loop it don't. It shows the question but the loop keeps going not letting the user to answer yes or no. I'm looking over SO and the internet and I can't fid any example or code like this, is what amb trying even possible?

This is my code:

changes.map(change => {
                      inquirer.prompt([{
                        name: "operate",
                        type: "confirm",
                        message: `Updatade database with ${change.description}?`,
                    }, ])
                    .then((operate) => {
                        if (operate.replace) {
                            green(
                                `Database has been updated`
                            );
                        } else {
                            red(
                                `Database hs not been updated`
                            );
                        }
                    });}

Also tried with async/await but I'm having the same issue.

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I found the issue. On the loop I was creating all the prompts with the same name therefore didn't result. After changing that now it works perfect.

about 4 years ago · Santiago Trujillo Denunciar
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