mokkabonna / inquirer-autocomplete-prompt

Autocomplete prompt for inquirer
ISC License
350 stars 82 forks source link

Returns empty answers with fuzzy object search #84

Closed junip closed 5 years ago

junip commented 5 years ago

Hi I am doing like this, but it answers returns empty string

function searchUser(answers, input) {
var names = [ { name: "Test1", accountId: "a746hsjikel" }, { name: "Test2", accountId: "982bjkkgkbnd" } ]
return new Promise(function(resolve) {
    setTimeout(function() {
      var options = {
        extract: function(el) {
          return el.name;
        }
      };
      var fuzzyResult = fuzzy.filter(input, names, options);
      resolve(
        fuzzyResult.map(function(el) {
          return el.string;
        })
      );
    }, 2000);
  });
}

inquirer
  .prompt([
    {
      type: "autocomplete",
      name: "test",
      message: "Search user",
      source: searchUsers,
      pageSize: 4,
      suggestOnly: true
    }
  ])
  .then(function(answers) {
    console.log(JSON.stringify(answers, null, 2));
  }); 
junip commented 5 years ago

Closing the issue , it is working fine after removing suggestOnly