Use value from list prompt in message for next question?
paul-uz opened this issue · 3 comments
paul-uz commented
I have a inquirer prompt with 2 questions, a list and then a choice. I want to use the selected value form the list in the message for the choice question.
Is this possible?
SBoudrias commented
Hi Paul, this should be possible. Here's some pseudo code showing an approach:
const answer1 = await input({ ... });
const answer2 = await select({
message: `... ${answer1} ...`,
choices: [...]
});
paul-uz commented
I'm using inquirer.prompt()
SBoudrias commented
It'd be the same idea, but slightly more verbose:
const { answer1 } = await inquirer.prompt([
{ name: 'answer1', ... }
]);
const { answer2 } = await inquirer.prompt([
{ name: 'answer2', message: `... ${answer1} ...`, ... }
]);