vendredi 1 mai 2015

How to set the `type` property of the serialized JSON object in Ember

I have a model named line-item in my ember application. When I try to create a line-item record, I observe in the network tab that ember serialises a JSON object that looks like so:

{
    data: {
        quantity: 1,
        type: "lineItems", // note this
        links: {
            cart: {linkage: {id: "7", type: "carts"}}
            product: {linkage: {id: "a65874aa87b", type: "products"}}
        }
    }
}

What I would like to do is change the value of the type property to line-items instead (since the backend expects that). I have tried overriding the serializeIntoHash and typeForRoot methods of the RESTSerializer class, but no luck there. I'm probably mucking around with the wrong methods, but I'm just not sure where I should be looking at instead.

I would really appreciate some pointers in the right direction.Thanks!




Aucun commentaire:

Enregistrer un commentaire