jeudi 1 octobre 2015

Catching data from REST api with ember data

i'm using the Ember Data to catch JSON objects in my API route, and i want be able to use a generic name in the result, not the name of the model.

For example, i have this JSON:

{
  event: [{
    _id: "55f660bdd80a0fd2e298f333",
    attributes: {
      description: "test",
      name: "name",
      is_active: false
    },
    type: "event"
  }, {
    _id: "560e1d0de4b0b27b28d5dd1b",
    attributes: {
      description: "test",
      name: "name",
      is_active: false
    },
    type: "event"
  }]
}

And is working, but i want change the name from "event" to "data", but this will cause a error:

WARNING: Encountered "data" in payload, but no model was found for model name "datum" (resolved model name using SiteApp.ApplicationSerializer.modelNameFromPayloadKey("data"))

I understand why the error, but i really need use DATA, is possible?

Thanks.




Aucun commentaire:

Enregistrer un commentaire