vendredi 28 avril 2017

Normalize responce JSONAPI with Ember Data

I have an application JSONSerializer, I want to be able to normalize the response as JSONAPI format. I created a normalizeFindRecordResponse but doesn't work when trying to retrieve a record, only works for creating records. My API only accepts JSON format, not JSONAPI.

normalizeFindRecordResponse(store, type, payload) {

        return {
          data: {
            attributes: payload.data.attributes,
            id: payload.data.id,
            links: payload.data.links,
            relationships:{
                paymethods: payload.data.paymethods,
                properties: payload.data.properties,
                transactions: payload.data.transactions
            },
            type: type.modelName,
            included: payload.data.included
          }
        };
    }




Aucun commentaire:

Enregistrer un commentaire