samedi 29 avril 2017

how do post to a nested route in emberjs

i have a route at /campaigns/{show} which displays a page with an action button 'join campaign'

i.e. /campaigns/{campaignId}
e.g. /campaigns/campaign-1

/apps/templates/campaigns/show.hbs:

...
 <button type="button" >join campaign</button>
...

/apps/controllers/campaigns/show.js:

import Ember from 'ember';

export default Ember.Controller.extend({
  actions: {
    joinCampaign: function() {
      // how to do a JSONAPI RESTful POST to /campaigns/{campaignId}/memberships ?
    }
  }
});

upon clicking the 'join campaign' button i wish to do a JSONAPI Restful POST to a rest service listening for a POST to /campaigns/{campaignId}/memberships

i have created the corresponding nested route in ember

i.e. /campaigns/{campaignId}/memberships
e.g. /campaigns/campaign-1/memberships




Aucun commentaire:

Enregistrer un commentaire