dimanche 29 janvier 2017

How to send data to server using ember.js Ember Data?

I'm trying to save (persist) data from the web application client using ember.js / Ember Data to the server which is accepting standard API calls. I have tried the code on the documentation but it just does not work. I also cannot find any example application as a guide.

The model is:

/app/models/account.js:

import DS from 'ember-data';

export default DS.Model.extend({
  username: DS.attr(),
  emailaddess: DS.attr(),
  birthdate: DS.attr(),
  gender: DS.attr()
});

/app/adapters/account.js:

import ApplicationAdapter from './application';

export default ApplicationAdapter.extend({

  urlForQueryRecord(query) {
    if (query.profile) {
      delete query.profile;
      return `${this._super(...arguments)}/profile`;
    }

    return this._super(...arguments);
  }

});

I'm asking for help for the code (including the adapter, model and template (.hbs) HTML button) working together to send data (using Ember Data) to the server. Thanks!




Aucun commentaire:

Enregistrer un commentaire