0

I got this code and I get { prize: 'Run' }, but I want to get "Run"

const inquirer = require("inquirer");

inquirer
  .prompt([
    {
      type: "list",
      name: "prize",
      message: "What do you want to do",
      choices: ["Run", "Settings",]
    }
  ])
  .then((answers) => { 
    console.log(answers);
  });

1 Answer 1

1
const inquirer = require("inquirer");

inquirer
  .prompt([
    {
      type: "list",
      name: "prize",
      message: "What do you want to do",
      choices: ["Run", "Settings",]
    }
  ])
  .then(({ prize }) => { 
    console.log(prize);
  });

You can destructure the object if you need. Prompt takes a list of questions so it cannot just resolve just a single for multiple questions.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.