@markkosho wrote:
I have a backend that follows the JSON API specification.
In my Ember app, I do something like this:
model() { return this.store.query('category', { filter: { forum: 'main' } }); }
This works well and the request sent to the server is
GET /categories?filter[forum]=main
. My app gets all the categories from the forum with IDmain
.Now, instead of the previous request, I would like to make a
GET /forums/main/categories
from the model. How can this be done in Ember with Ember Data?Here's something I tried with Ember AJAX:
ajax: Ember.inject.service(), model() { return Ember.RSVP.hash({ categories: this.get('ajax').request('/forums/main/categories'), }); }
The request works and the correct data is returned from the server. But Ember Data just doesn't know about it and I can't use the model in my template. How can I make Ember AJAX work with Ember Data?
The Ember AJAX GitHub page proposes to write something like that:
import DS from 'ember-data'; import AjaxServiceSupport from 'ember-ajax/mixins/ajax-support'; export default DS.JSONAPIAdapter.extend(AjaxServiceSupport);
But it doesn't seem to change anything.
Any help would be appreciated. Thank you.
Posts: 1
Participants: 1