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:

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
2016-11-30 16:49:56
Comments
Leave a Comment

Please login to continue.