Reputation: 9587
I'm trying to retrieve some JSON content files using Ember Data, but it doesn't seem to be possible based on the convention of the library...
But, maybe I'm wrong.
I'm basically trying to retrieve my model "content" with the id "en":
this.store.find('content', 'en');
And I would like Ember Data to send the request to this URL:
/content/en.json
But it's trying using this url:
/content/contents/en
Is there a way to change the request path to what I need in the adapter?
Thanks.
Upvotes: 0
Views: 63
Reputation: 874
You can fully personalize your request with adapter.
Just make an ApplicationAdapter
or a ContentAdapter
which extends the RESTAdapter or any other default Adapter
App.ApplicationAdapter = DS.RESTAdapter.extend({
});
And modify the buildURL
and pathForType
here is a link to the default implementation to buildURL https://github.com/emberjs/data/blob/v1.0.0-beta.14.1/packages/ember-data/lib/adapters/rest_adapter.js#L516
Im just confused about your URL however : it should be /contents/en
by default and not /content/contents/en
are yous ure you didn't add a prefix
or a tricky host
configuration.
with a default config the follow should do the trick for your case
App.ContentAdapter=DS.RESTAdapter.extend({
buildURL : function(){
var default=this._super();
return default+".json";
},
pathForType : function(){
return Ember.String.decamelize(type);
}
});
Upvotes: 1