0
votes

I am working with ember to do tutorial.

and trying to connect it with rest adapter to go backend.

full go to do app works, but when I try to save model, it does send post to api endpoint, which returns the Id of the newly saved model, but it do not reflect in the client side.

if I full reload all data, it works, but for a single model, the returned Id do not gets updated.

as my model do not have "id", it uses primaryKey: 'Id', which works on page reload, but when server response after save, the returned ID data do not updated inside client side.

how do I more debug the error ?

ok I got partial solution.

my server was returning only data as

{
   "Id": 4767482418036736,
   "title": "asdfas"
  }

instead of

todo:{
   "Id": 4767482418036736,
   "title": "asdfas"
  }

but as I can not change my server much, I do I teach ember to look for todo without braces ??

2

2 Answers

0
votes

Your JSON response does not look to me formatted correctly, see https://github.com/emberjs/data/blob/master/packages/ember-data/tests/integration/adapter/rest_adapter_test.js for examples).

Given you can not change the server, look into Serializers (http://emberjs.com/api/data/classes/DS.RESTSerializer.html)

0
votes

I got the answer,

I needed to override ExtractSingle serializer function this way.

extractSingle:(store, type, payload, id)->
    payload = { todo : payload }
    return this._super(store, type, payload, id);