jeudi 20 octobre 2016

Ember data POST returns empty payload

Cannot understand why model isn't updating after POST

Ok, I'm very new to Ember so this is probably a very "noob" question. I have a model that's populated and then I call save(). This sends the JSON data to my database via the RESTAdapter.

My database saves the record as raw JSON just as it was received by the client except it adds an ID and then returns the same model back.

In Chrome, I can see the request go out and come back successfully, but I keep getting this error message in the console and the newly created model is still "dirty".

ember.debug.js:19154 Error: Ember Data Request POST http://localhost:9991/v1/resources/troubleTickets returned a 0
Payload (Empty Content-Type)
    at new Error (native)
    at Error.EmberError (http://localhost:4200/assets/vendor.js:29610:21)
    at Error.AdapterError (http://localhost:4200/assets/vendor.js:83234:16)
    at Class.handleResponse (http://localhost:4200/assets/vendor.js:84513:14)
    at ajaxError (http://localhost:4200/assets/vendor.js:85011:25)
    at Class.hash.error (http://localhost:4200/assets/vendor.js:84585:23)
    at fire (http://localhost:4200/assets/vendor.js:3617:31)
    at Object.fireWith [as rejectWith] (http://localhost:4200/assets/vendor.js:3747:7)
    at done (http://localhost:4200/assets/vendor.js:9556:14)
    at XMLHttpRequest.<anonymous> (http://localhost:4200/assets/vendor.js:9788:10)

Here's what the JSON record looks like that's sent to the server and the returned JSON matches this exactly except for having and "id" attribute added:

{  
   "data":{  
      "attributes":{  
         "synopsis":"SYNOPSIS",
         "description":"Ea eaque iusto veritatis nihil nisi incidunt, doloribus quia eum quae recusandae. Ipsum.",
         "severity":null,
         "priority":null,
         "network":null,
         "date-submitted":"2016-10-20T17:31:41.691Z",
         "date-resolved":null,
         "date-verified":null,
         "sme":null,
         "resolution":null,
         "resolution-desc":null,
         "current-status":"New",
         "date-last-contact":null,
         "orig-phone":"+612-75-8202261",
         "orig-address":null,
         "orig-first-name":"Kameko",
         "orig-last-name":"Crane",
         "orig-email":"sihoregew@yahoo.com",
         "sub-first-name":"Noble",
         "sub-last-name":"Booth",
         "sub-phone":"+685-74-6686467",
         "sub-email":"tiran@gmail.com"
      },
      "type":"trouble-tickets"
   }
}

What am I missing here? BTW... I'm using Ember 2.8.0




Aucun commentaire:

Enregistrer un commentaire