mardi 10 mai 2016

EmberJS - adapter dynamic namespaces for various models

I have an app in EmberJS and RESTful API. Problem is that some resources require dynamic URLs.

For example addresses are a part of contact (with some contact id). So route for adding address in API is

/api/contacts/3/addresses

So I want to query addresses in JSONAPIAdapter in Ember. How Can I do it nicely? I use:

this.store.adapterFor('application').set('namespace', "api/contacts/3");

But it's ugly, I should be using it before every model, and that's really bad solution. Do I need to rewrite whole JSONAPIAdapter, or there is some other solution?




Aucun commentaire:

Enregistrer un commentaire