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

325
Views
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 answers
Answer question

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 Report
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!