Here in this particular case, I have an array sections
, which contains the object required for inquirer prompt.
For Ex, sections[5] may look like:
console.log(JSON.stringify(sections[5], null, ' ');
/** Structure is as follows:
[
{
"name": "firstName",
"type": "input",
"message": "Enter your first name"
},
{
"name": "secondName",
"type": "input",
"message": "Enter your second name"
}
]
*/
Now I want to prompt for each of object stored in sections
array, how can I do that without that long hardcoded nesting using then.?
For now, it looks something like.
inquirer.prompt(sections[1]).then(function(){
inquirer.prompt(sections[2]).then(function(){
inquirer.prompt(sections[3]) // and so on...
I want to simplify this. Thanks.
I don't know why but the question is marked as a duplicate of something which is not even close to this. Please take care of this.