payloadKeyFromModelName (modelName) String
You can use payloadKeyFromModelName to override the root key for an outgoing request. By default, the RESTSerializer returns a camelized version of the model's name.
For a model called TacoParty, its modelName would be the string taco-party. The RESTSerializer will send it to the server with tacoParty as the root key in the JSON payload:
{
"tacoParty": {
"id": "1",
"location": "Matthew Beale's House"
}
}
For example, your server may expect dasherized root objects:
app/serializers/application.jsimport DS from 'ember-data';
export default DS.RESTSerializer.extend({
payloadKeyFromModelName: function(modelName) {
return Ember.String.dasherize(modelName);
}
});
Given a TacoParty model, calling save on it would produce an outgoing request like:
{
"taco-party": {
"id": "1",
"location": "Matthew Beale's House"
}
}
Parameters:
-
modelName
String
Returns:
-
String
Please login to continue.