mardi 5 avril 2016

How can I use Ember Data custom api with json-api?

Before I use json-api, I custom ember data api like this:

import DS from 'ember-data';
import config from './../config/environment';

export default DS.Model.extend({
  ...

  useRepairPackage(repairPackageId) {
    Ember.$.ajax({url: `${config.host}/${config.namespace}/quotations/${this.get('id')}/use_repair_package.json`, type: "PATCH", data: {...}}).then((result)=> { 
      return this.reload();
    }); 
  }
});

But when I use json-api, data: {...} is more complex and I must make up json by myself.

It had best way to solve this problem? Thanks.




Aucun commentaire:

Enregistrer un commentaire