Created
October 7, 2013 20:10
-
-
Save davidpett/6874122 to your computer and use it in GitHub Desktop.
I am trying to populate all of the post items and the /posts api call returns reference ids, so in turn I am making a call for each id to populate the array, but it is not working, help?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.Post.reopenClass({ | |
find: function(id) { | |
return Ember.$.getJSON('/posts/' + id).then(function(data) { | |
return App.Post.create(data); | |
}); | |
}, | |
findAll: function() { | |
return Ember.$.getJSON('/posts').then(function(data) { | |
var items = Ember.A(); | |
data.nodes.forEach(function(data) { | |
items.pushObject(App.Post.find(data.id)); | |
}); | |
return items; | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment