Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4830

Saving a new record, how should JSON API response look like?

$
0
0

@Bauke wrote:

I recently switched to JSON API but I run into trouble when saving a new record. Say I created a record of the model type foobar and save it:

let record = this.get('store').createRecord('foobar', {
  name: 'whheeeeee'
});
record.save().then(function(record) {
  console.log('record saved: ' + record.get('id'));
});

And the server reponse looks like this:

{
  'data': [
    {
      'type': 'foobar',
      'id': 'foobar_id_123'
    }
  ]
}

No error of whatsoever, but apparently the response is not synced with the actual record in the store. The ID of the record is still null!

It worked in REST. So how do I fix this?

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4830

Trending Articles