samedi 5 novembre 2016

Ember data createRecord creates multiple records

When I inspect Data in ember inspector I see multiple record one with id(int) and one without id(null).

Using ember 2.9.1

save: function(){
  var title= this.get('title');
  this.store.createRecord('post',{ title:title }).save();
  this.setProperties({ title:''});
  this.transitionToRoute('posts');
}

Node Backend

router.post('/', function(req, res, next) {
  post.create({
    title: req.body.data.attributes.title
  }).then(function () {
    res.set('Content-Type','application/vnd.api+json');
    return res.send({
      "post": "created successfully",
      data:null
    });
  });
});




Aucun commentaire:

Enregistrer un commentaire