mardi 16 août 2016

Ember: attributes of type object

The API I call returns data like:

{
  "data": {
    "id": "5",
    "type": "person",
    "attributes": {
      "name": "John",
      "pet": {
        "typeOf": "cat",
        "petName": "Furry"
      },
      ...

models/person.js:

name: attr('string'),
pet: attr('')

template:



This works for name but not for pet. Do I have to create a pet model even though there's no API call for pets? Will this even work, as the API returns pet as an object attribute, and not a relationship?




Aucun commentaire:

Enregistrer un commentaire