Ember.js Error: statement failed: response from findAll must be an array, not undefined

Perhaps this is the dumbest question, but still - how to manually request a server for records of a specific model?

App.UrlNewRoute = Ember.Route.extend({
  setupController: function(controller, model) {
    console.dir(1);
    this.store.find('UrlType').then(function(url_types) {
      controller.set('urlTypes',url_types);
    });
  }
});    

{"url_types":[{"id":1,"caption":"text link"},{"id":2,"caption":"guest post"},{"id":3,"caption":"blog comment"},{"id":4,"caption":"banner"},{"id":5,"caption":"profile"},{"id":6,"caption":"review"}]}
+4
source share
1 answer

completely legitimate question

you should request it with camelCase:

this.store.find('urlType')

and your json key should also be camelCase(you can also use a serializer to fix it):

{
   "urlTypes":[
      {
         "id":1,
         "caption":"text link"
      },
      {
         "id":2,
         "caption":"guest post"
      },
      {
         "id":3,
         "caption":"blog comment"
      },
      {
         "id":4,
         "caption":"banner"
      },
      {
         "id":5,
         "caption":"profile"
      },
      {
         "id":6,
         "caption":"review"
      }
   ]
}

http://emberjs.jsbin.com/OxIDiVU/301/edit

+2
source

Source: https://habr.com/ru/post/1532840/


All Articles