DS.JSONSerializer#normalizeResponse()

normalizeResponse (store, primaryModelClass, payload, id, requestType) Object

Inherited from DS.Serializer but overwritten in addon/serializers/json.js:202
Available since 1.13.0

The normalizeResponse method is used to normalize a payload from the server to a JSON-API Document.

http://jsonapi.org/format/#document-structure

This method delegates to a more specific normalize method based on the requestType.

To override this method with a custom one, make sure to call return this._super(store, primaryModelClass, payload, id, requestType) with your pre-processed data.

Here's an example of using normalizeResponse manually:

1
2
3
4
5
6
7
8
socket.on('message', function(message) {
  var data = message.data;
  var modelClass = store.modelFor(data.modelName);
  var serializer = store.serializerFor(data.modelName);
  var normalized = serializer.normalizeSingleResponse(store, modelClass, data, data.id);
 
  store.push(normalized);
});

Parameters:

store DS.Store
primaryModelClass DS.Model
payload Object
id String|Number
requestType String

Returns:

Object
JSON-API Document
doc_EmberJs
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.