jeudi 1 octobre 2015

Emberdata How to make a request on a dynamic segment

This is my router:

Router.map(function() {
  this.route('merchant', { path:'/merchant/:id' }, function() {
    this.route('product-tag');

Currently my api works like this. So I'm trying to get all the product tags that belong to merchant with id: 1781.

http://localhost:3001/merchant/1781/product_tags

The closest I've gotten is using a the product-tag route doing something like this:

model: function() {
  debugger;
  var parentModel = this.modelFor('merchant').merchant;
  return this.store.find('product-tag', { merchant_id: parentModel.id});
}

This will generate a request:

http://localhost:3000/product_tags?merchant_id=1781

I'd assume that because product_tag is a subroute of merchant it'd take into account the dynamic segment of merchant but that doesn't seem to be the case.

Thanks for the help.

Aucun commentaire:

Enregistrer un commentaire