title: TypeError: data[0] is undefined
body: <p>I want to make an input file autocomplete when the user starts to type. I have tried, but when I start to type in input file it says <code>TypeError: data[0] is undefined</code></p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div class="col-md-4"&gt;
   &lt;input name="name" class="form-control" id="typeahead" type="text" placeholder="Type here" 
     data-provide="typeahead" data-items="10" /&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>jQuery:</p>
  
  <pre><code> $('#typeahead').typeahead({
  
  
      source: function (query, process) {
  
          return $.getJSON(
              'api/usergroup/listdetails',
              { query: query },
              function (data) {
                  var newData = [];
                  $.each(data, function () {
  
                      newData.push(this.name);
                  });
  
                  process(newData); return;
              });
      }
  });
  </code></pre>
  
  <p>Can anyone tell me what is wrong here?</p>