ember.js - Ember js handling API endpoints with nested resource URLs -


a portion of api setup follows:

/v1/place/:place_uuid - retrieve place

/v1/place/:place_uuid/cart - retrieve shopping cart object associated place

my routes setup correctly (see below) api requests made ember don't match own.

app.router.map(function() {     this.resource('place', { path: '/:place_uuid' }, function() {         this.resource('category', { path: '/:category_uuid' }, function() {             this.resource('product', { path: '/:product_uuid' });         });         this.resource('cart', { path: '/cart' });     }); }); 

when load /:place_uuid in browser see api request /v1/place/:place_uuid correct. route renders returned object.

when load /:place_uuid/cart in browser see same above 2nd api request /v1/carts. fine except /v1/carts url. need /v1/place/:place_uuid/cart

i tried use buildurl custom adapter cart model.. no luck. don't have access place_uuid anywhere below can't inject in.

cartadapter = app.adapter.extend({   buildurl: function(record, suffix) {     console.log(record); // string.      var url = [this.url];     url.push('places');     url.push(place_uuid); // if had access place_uuid inject here     url.push('cart');     return url.join("/");   } }); app.store.registeradapter('app.cart', cartadapter); 

it great if use original api endpoint, suppose option change endpoint /v1/carts?place_uuid=:place_uuid (which ember seems prefer, bit tricky don't work on backend).

any advice appreciated.

ember not support nested rest urls/resources yet. there open issue functionality can monitor.


Comments