vendredi 27 avril 2018

Ember JsonApi Serialize override normalizeResponse. How to interpret the parameters

I use the JsonApiSerializer in JSON and I want to override standard behavior. I want to behavior to be different for certain models. Therefore I would like check the paramter primaryModelClass, but how do I interpret that parameter. I have tried to inspect it but all I get is "unknown mixin".

I have looked at the documentation here:

https://emberjs.com/api/ember-data/3.0/classes/DS.JSONAPISerializer/methods/normalizeResponse?anchor=normalizeResponse

I have this piece of code

import DS from 'ember-data';
export default DS.JSONAPISerializer.extend({
    normalizeResponse: function(store, 
                                primaryModelClass, 
                                payload, id, requestType) {
    console.log(primaryModelClass.toString());
...

It outputs (unknown mixin)

How do I fint the model type in the normalizeResponse method?

I use Ember 3.0.




Aucun commentaire:

Enregistrer un commentaire