mercredi 16 septembre 2015

Ember-data: Empty payload with .save()

Im stuck trying to.save() a record using Ember-Data 1.3 đŸ˜”

When I perform a .save() nothing goes wrong but the request payload is empty:

Ember-data PUT request

I'm pretty convinced it's an issue with the ember-data request because from the back-end side the only data I got it's "token=blahblahblah". Also I took the request (copy as cURL) and I confirm it's empty:

enter image description here

Here's the .save() code:

    var self = this;
        this.set('isLoading',true);
        return this.store.find('feed', feed_id).then(function(feed) {
            //Setting the system_status of the feed to either 4 (archived) or 1 (normal)
            feed.set('system_status',param);
            //Persist to change to store (and server)
            console.log(feed);
            feed.save().then(function(){
                //success
                self.set('isLoading',false);
                alert('ok');
            },function(){
                //Error
                self.set('isLoading',false);
                alert('error');
            }) // => PUT to /feeds/id
        });

RESTAdapter:

export default DS.RESTAdapter.extend({
host: 'http://localhost:8000/',
namespace: 'ed',
headers: {
    "Content-type": "x-www-form-urlencoded" // workaround for laravel
}});

Model console.log before .save()

enter image description here

Any ideas?




Aucun commentaire:

Enregistrer un commentaire