Inquirer.js
Inquirer.js copied to clipboard
[Question] How can I have an input question with prefilled data?
My problem is: I create a dynamic name based on some informations asked before and I want to check with the user if the name is good, otherwise they can fix whatever the way they want.
I'd like to do something like this:
const answers = await this.prompt([
{
type: 'input',
name: 'fixed',
message: 'Ok, you can fix the name now',
value: nameToBeFixed
},
]);
How can I do that?
Thanks in advance!
Usually, you use default.
default: (String|Number|Boolean|Array|Function) Default value(s) to use if nothing is entered, or a function that returns the default value(s). If defined as a function, the first parameter will be the current inquirer session answers.
Unless you mean you want the input to be PREPOPULATED with something, so the user can backspace over it?
@kschang77 Do you have an example of how to pre-populate the value for an input type (editable)?
I'm looking for "PREPOPULATED " too.
Hello, I'm looking for a pre-populated answer too (to be editable, not default) @brlebtag did you manage it ?
Thanks
Sorry guys. I didn't see the messages.
@kschang77 Yeah I want it to be pre-populated and the user can later edit it. So it is not just a default option.
@thiboot No, I didn't.