payloadTypeFromModelName (modelname) String
public
payloadTypeFromModelName
can be used to change the mapping for the type in the payload, taken from the model name.
Say your API namespaces the type of a model and expects the following payload when you update the post
model:
// POST /api/posts/1 { "data": { "id": 1, "type": "api::v1::post" } }
By overwriting payloadTypeFromModelName
you can specify that the namespaces model name for the post
should be used:
app/serializers/application.js
import DS from "ember-data"; export default JSONAPISerializer.extend({ payloadTypeFromModelName(modelName) { return "api::v1::" + modelName; } });
By default the payload type is the pluralized model name. Usually, Ember Data can use the correct inflection to do this for you. Most of the time, you won't need to override payloadTypeFromModelName
for this purpose.
Also take a look at modelNameFromPayloadType to customize how the model name from should be mapped from the payload.
Parameters:
-
modelname
String
- modelName from the record
Returns:
-
String
- payloadType
Please login to continue.