Reputation: 38613
Ember data send data to the server with the model name embedded.
{
"part" {
"name" : "test1",
"quantity" : 12
}
}
I want the "part" field removed from the response so it would look like:
{
"name" : "test1",
"quantity" : 12
}
I need this to be generic so it will work for any model in my store.
ok I found the part that does in RESTAdapter.
serializeIntoHash: function(data, type, record, options) {
var root = underscore(decamelize(type.typeKey));
data[root] = this.serialize(record, options);
},
I tried to remove the root part
serializeIntoHash: function(data, type, record, options) {
data = this.serialize(record, options);
}
But it does not work, it response with {}
Upvotes: 4
Views: 1018
Reputation: 46
https://github.com/san650/ember-cli-page-object/issues/153
Ember.merge
is deprecated, use Ember.assign
App.ApplicationSerializer = DS.RESTSerializer.extend({
serializeIntoHash: function(hash, type, record, options) {
Ember.assign(hash, this.serialize(record, options));
}
});
Upvotes: 3
Reputation: 38613
OK found it: https://github.com/emberjs/data/issues/771
App.ApplicationSerializer = DS.RESTSerializer.extend({
serializeIntoHash: function(hash, type, record, options) {
Ember.merge(hash, this.serialize(record, options));
}
});
Upvotes: 8