Skip to content

Instantly share code, notes, and snippets.

@davidpett
Created October 7, 2013 20:10
Show Gist options
  • Save davidpett/6874122 to your computer and use it in GitHub Desktop.
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?
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