vendredi 21 octobre 2016

Ember not detecting all attributes from server response

The response from the server seems correct but ember doesn't seem to load the response properly into the data. Below is the response from findQuery() on feedstories:

findQuery Response

After creating the record, the server sends the following response. Which seems correct as it is an individual record creation.

create record response

Ember loads the story_type post, but as you can see the other attributes such as global_id (which has been set to primary key in the serializer) has not been loaded. The embedded story attribue has the same problem, where some of the information is correct, (body, title, etc.) but doesn't load all the other attributes. They are set as undefined.

Ember Inspector

I think there may be something wrong with how I serialize the data on the client side. But as some of the information is being loaded, I'm not too sure. Any ideas?

Here is the adapter and serializer below:

App.FeedstorySerializer = DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
    primaryKey: 'global_id',
    attrs: {
        pin: {embedded: 'always' },
        story: {embedded: 'always'},
    },
    serializeIntoHash: function(hash, type, record, options){
        // Removed the root element from the request payload.
        // If not completed, causes issue when getting data from
        // the bundle object on the server.
        Ember.merge(hash, this.serialize(record, options));
    },
});


App.FeedstoryAdapter = App.ApplicationAdapter.extend({
    buildURL: function(type, id, record){
        this._super();
        url = '/' + this.namespace + '/feedstories/'
        return url
    }
});




Aucun commentaire:

Enregistrer un commentaire