I am building a small CLI app using javascript, yargs, inquirer, and superagent. In inquirer I am asking the user to enter a choice of miles to be used in my app. I want to use that value somewhere else in my app but I can't seem to able to get the value returned. Below is my latest attempt. Any help into getting this value returned from selectRange
would be highly appreciated.
const selectRange = (result) => {
return inquirer.prompt([{
type: 'checkbox',
message: 'Select the range in miles to search',
name: 'miles',
choices: ['50', '100','150', '200', '250'] ,
validate: (result) => {
if (result.length > 1) {
return 'Error: You must select 1 choice only'
} else {
return true
}
},
filter: input => {
return input
}
}]).then(input => {
return input
})
}
const surroundingCitiesWeather = (location) => {
const range = selectRange()
console.log(`Range selected is ${range}`)
}