vendredi 3 juin 2016

Ember-data error: "Assertion Failed: You need to pass a model name to the store's modelFor method"

I'm getting this error when trying to consume the json from the backend. I'm using Ember CLI version 2.5.0 and the RestAdapter.

Here's my routes/products/index.js looks like:

export default Ember.Route.extend({
  actions: {
   [...]
  },
  model: function() {
    return this.store.findAll('product');
  }
});

And here's what my json looks like:

{
   "products":[
      {
         "id":10,
         "name":"Pacote Ração 18 Kg",
         "price_cents":1500,
         "margin_cents":0,
         "commission":0,
         "expiration":null,
         "track_stock":false,
         "stock_amount":5,
         "brand":{
            "id":2,
            "name":"SuperPet"
         },
         "group":{
            "id":1,
            "name":"Rações"
         }
      },
      {
         "id":9,
         "name":"Pacote Ração 16 Kg",
         "price_cents":1500,
         "margin_cents":0,
         "commission":0,
         "expiration":null,
         "track_stock":false,
         "stock_amount":5,
         "brand":{
            "id":2,
            "name":"SuperPet"
         },
         "group":{
            "id":1,
            "name":"Rações"
         }
      },
      {
         "id":8,
         "name":"Pacote Ração 14 Kg",
         "price_cents":1500,
         "margin_cents":0,
         "commission":0,
         "expiration":null,
         "track_stock":false,
         "stock_amount":5,
         "brand":{
            "id":1,
            "name":"Whiskas"
         },
         "group":{
            "id":1,
            "name":"Rações"
         }
      }
   ],
   "meta":{
      "pagination":{
         "per_page":null,
         "total_pages":4,
         "total_objects":10
      }
   }
}




Aucun commentaire:

Enregistrer un commentaire