title: Ember, can't assign a variable inside an AJAX call
body: <p>So I am trying to assign a variable, it runs ok if there is no ajax call but trying to assign the response does not work (response data is ok, I can console.log it)
  Here is my component code, upon editing the objects array anywhere but in the ajax call it updates correctly.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import Component from '@ember/component';
  import Ember from 'ember';
  
  export default Component.extend({
  
    objects: [],
  
    actions: {
      loadObjects: function() {
        Ember.$.ajax({
          url: &lt;API URL&gt;,
          type: "GET"
  
        }).then(function(resp) {
          this.set('objects', resp);
          console.log(resp);
        });
      }
    }
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>Any idea? Been smashing my head for hours</p>
  
  <p>EDIT: Working thanks to @Dmitry, here is the working solution</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import Component from '@ember/component';
  import Ember from 'ember';
  
  export default Component.extend({
  
    objects: [],
  
    actions: {
      loadObjects: function() {
        Ember.$.ajax({
          url: &lt;API URL&gt;,
          type: "GET"
  
        }).then(resp =&gt; {
          this.set('objects', resp);
        });
      }
    }
  });</code></pre>
  </div>
  </div>
  </p>