lundi 2 mai 2016

Ember.js save() after createRecord sends empty req.body to my express.js server

When I use createRecord and then save, the express server receives the post request but the req.body is empty. I made the same post request using Postman and it works perfectly. The get request works too in the tasks template displaying the tasks in a list.

This is my ember code:

Route (tasks.js):

import Ember from 'ember';

export default Ember.Route.extend({
  model() {
    return this.store.findAll('task');
  },
  actions: {
   addTask() {
     const task = this.store.createRecord('task', {
       title: this.get("controller.title")
     });

     task.save();

   }
 }
});

Model (task.js):

import Model from 'ember-data/model';
import DS from 'ember-data';


export default Model.extend({
  title: DS.attr('string')
});

Template (tasks.hbs):


<button id="add-task" >Add</button>

<br><br>


    <br>




I'm using the default ember JSONAPIAdapter.




Aucun commentaire:

Enregistrer un commentaire