mercredi 17 octobre 2018

How to use route's params in adapter in Ember.js?

Imagine we have an app that allows a user to collect cards and make decks of their cards.

Also, imagine we have in router:

this.route('cards');
this.route('decks', function() {
    this.route('deck', {path: ':deck_name'});
});

And two API endpoints:

  1. GET /cards — to query all cards controlled by a user
  2. GET /decks/:deck_name/cards — to query all cards in the deck with certain deck_name controlled by a user

We have a model of card and want to make different requests depending on the current route (to the first endpoint for our app's /cards route, and to second for /decks/:deck_name route).

How to write an adapter for card model to query the right endpoint depending on the route?


We use Ember v2.18.




Aucun commentaire:

Enregistrer un commentaire