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.

demo: http://jsfiddle.net/rmfrt/


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -