getting error when trying to use ajax with select2
<p>Any idea how to debug the ajax funtionality of select2? Here's an example of what I'm trying to implement: <a href="https://jsbin.com/sohupoviko/edit?html,output" rel="nofollow noreferrer">https://jsbin.com/sohupoviko/edit?html,output</a> and 
here's the result set for <a href="http://localhost:4000/users" rel="nofollow noreferrer">http://localhost:4000/users</a>:</p>

<pre><code>[
  {
    "id": 1,
    "first_name": "John",
    "last_name": "Smith"
  },
  {
    "id": 2,
    "first_name": "John2",
    "last_name": "Smith2"
  }
]
</code></pre>

<p>This is the local error being returned when I run the code locally:</p>

<pre><code>jquery.min.js:2 jQuery.Deferred exception: Cannot read property 'length' of undefined TypeError: Cannot read property 'length' of undefined
    at d (https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js:2:5214)
    at Object.f.transport.d.status.0.d.status.e.trigger.message (https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js:2:4227)
    at j (http://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js:2:29948)
    at k (http://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js:2:30262) undefined
</code></pre>

<p>Any idea what the root cause might be or how to debug?</p>