lundi 20 février 2017

Request to specific nested url by DS.store methods

I have following code in route:

  model(params) {
    return this.store.findRecord('user', params.id)
  }

And how expected, it request to:

/users/{somethingId}

But my route in external api is nested and it looks like:

/partners/{somethingId}/users

Because of this, i need make something request like:

/partners/{somethingId}/users or /partners/{somethingId}/users/{userId}

I tried Ember's relationships but it didn't help me. I got url with params:

return this.store.findRecord('partner', params.id, {include:'users'});
// api/partners/5?include=users

I also tried method store.adapterFor and it was changing namespace of my adapter immediately before each request:

this.store.adapterFor('application').set('namespace', '/api/partners/' + params.id);

But making this thing all time before each request would be dirty, so I don't want going this way.

I know i can use something like ajax-ember but i'd like to use DS.store with adapters. Any help will be appreciated.




Aucun commentaire:

Enregistrer un commentaire