
In a repo route we need to find record by slug there is no easy way to do it with a public finders API, so we need to use adapter and serializers directly. The problem is that the old way of doing this didn't use the normalizePayload function and also it didn't add included records properly. New code properly normalizes response and adds all of the embedded records that were extracted from the response.
17 lines
432 B
JavaScript
17 lines
432 B
JavaScript
import Ember from 'ember';
|
|
import V2FallbackSerializer from 'travis/serializers/v2_fallback';
|
|
|
|
var Serializer = V2FallbackSerializer.extend({
|
|
isNewSerializerAPI: true,
|
|
|
|
normalizeResponse(store, primaryModelClass, payload, id, requestType) {
|
|
if(!id && requestType == 'findRecord') {
|
|
id = payload.id;
|
|
}
|
|
|
|
return this._super(store, primaryModelClass, payload, id, requestType);
|
|
}
|
|
});
|
|
|
|
export default Serializer;
|