mercredi 23 septembre 2015

JSONAPISerializer not returning underscore case to API

I am trying to retrieve a single record by returning

singleGroup: this.store.findRecord('individual_group', group_id)

I am then getting this error in the console:

GET http://localhost:4200/api/v1/individual-groups/349 404 (Not Found)

where it seems to be dasherizing individual_groups to individual-groups

Now in the API documentation, an individual group is found by doing a GET request to api/v1/individual_groups/:id

I'm using the JSONAPIAdapter and already have a serializer set up as so:

export default DS.JSONAPISerializer.extend({
    keyForAttribute: function(attr) {
        return Ember.String.underscore(attr);
    },
    keyForRelationship: function(attr) {
        return Ember.String.underscore(attr);
    }
});

but it does not seem to be affecting this particular case.

Is there a way to make sure that when I call this.store.findRecord('individual_group', group_id) it will make the request to the API using

GET http://localhost:4200/api/v1/individual_groups/349

instead of

GET http://localhost:4200/api/v1/individual-groups/349




Aucun commentaire:

Enregistrer un commentaire