0
votes

The Ember.js REST Adapter expects the JSON to be returned as:

{
    "customer": {
         "CustomerID": "ALFKI",
        "CompanyName": "Alfreds Futterkiste",
        "ContactName": "Maria Anders",
        "ContactTitle": "Sales Representative",
        "id": "b0d16ed0-c901-4ca3-ba41-7fc74c96909f"
   }
}

But my API returns the data without a root element:

{
        "CustomerID": "ALFKI",
        "CompanyName": "Alfreds Futterkiste",
        "ContactName": "Maria Anders",
        "ContactTitle": "Sales Representative",
        "id": "b0d16ed0-c901-4ca3-ba41-7fc74c96909f"
}

I find a question here: Ember.js REST Adapter without JSON root, but the answers is too old, don't works in the newest version of ember and ember-data.

Sorry for my poor English, hope that's clear...

1

1 Answers

1
votes

Override serializeIntoHash in the serializer:

serializeIntoHash: function(data, type, record, options) {
    Ember.merge(data, this.serialize(record, options));
}

For your second question, look at typeForRoot. Why not just read the entire page on adapters?