Ember.js REST Adapter without JSON root

后端 未结 5 1308
Happy的楠姐
Happy的楠姐 2020-12-06 18:56

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

{
    \"person\": {
        \"first_name\": \"Barack\",
        \"last_name\": \"Obama\",
              


        
5条回答
  •  我在风中等你
    2020-12-06 19:20

    You could also normalize it into something ember would expect.

    App.PersonSerializer = DS.RESTSerializer.extend({
      normalizePayload: function(type, payload) {
        var typeKey = type.typeKey;
        return {
          typeKey: payload
        }
      }
    });
    

提交回复
热议问题