javascript - Getting a JSON response with ember -
i trying experimenting ember js. instead of fixtures use api.
this code using data:
app.itemsroute = ember.route.extend({ model: function() { return $.getjson('http://someurl.json').then(function(data) { return data.items_popular.map(function(item) { return item; }); }); } }); this json file looks like:
{ "popular":{ "items_popular":[ { "id":"23", "item":"some title", "url":"http://url", "user":"girl" }, { "id":"56", "item":"title of item 2", "url":"http://url", "user":"guy" } ] } } currently keep getting
cannot call method 'map' of undefined would appreciate refactoring request
you're accessing data.items_popular, should data.popular.items_popular.
Comments
Post a Comment