title: Ajax without ember data - Uncaught TypeError: Object #<Object> has no method 'forEach'
body: <p>I'm attempting to build a non blocking async call in an Ember.js app without using Ember Data. </p>
  
  <p>I have the following Ember.js model:</p>
  
  <pre><code>App.Player = Ember.Object.extend({
      id: '',
      alias: '',
      name: '',
      twitterUserName: '',
      isFeatured: ''
  });
  
  App.Player.reopenClass({
      getPlayers: function () {
          var players = Ember.ArrayProxy.create({ content: [] });
          $.getJSON("/api/players").then(function (response) {
              response.forEach(function (p) {
                  players.pushObject(App.Player.create(p));
              });
          });
          return players;
      }
  });
  </code></pre>
  
  <p>And I am calling it as follows in my route:</p>
  
  <pre><code>App.IndexRoute = Ember.Route.extend({
      model: function (params) {
          return App.Player.getPlayers();
      }
  });
  </code></pre>
  
  <p>For some reason I am getting the following javascript error:</p>
  
  <p>Uncaught TypeError: Object # has no method 'forEach'</p>
  
  <p>I've tried a few variants I have seen around but nothing seems to work.  Any help would be appreciated...</p>
  
  <p>EDIT - Found the solution with some help from Darshan, here's the working code:</p>
  
  <pre><code>App.Player.reopenClass({
      getPlayers: function () {
          var players = [];
          $.ajax({
              url: "/api/players",
          }).then(function (response) {
              response.players.forEach(function (player) {
                  var model = App.Player.create(player);
                  players.addObject(model);
              });
          });
          return players;
      }
  });
  </code></pre>