Reputation: 4115
I am working with Ember and attempting to retrieve data from my REST API, but it is not working as intended. First of all i am quite unsure how to debug RESTAdapters and second of all i don't see the call being made in the Chrome Devtools Network view.
HTML:
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.min.js"></script>
<script src="http://builds.emberjs.com/release/ember.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.0.0-beta.11/ember-data.js"></script>
Here is my JS:
App = Ember.Application.create();
App.Store = DS.Store.extend({
adapter: DS.RESTAdapter.extend({
host: 'http://example.com/api'
})
});
App.Bodypart = DS.Model.extend({
name: DS.attr('string')
});
App.ApplicationRoute = Ember.Route.extend({
model: function() {
return App.Bodypart.find();
}
});
My console returns:
Error while processing route: index undefined is not a function TypeError: undefined is not a function
I understand this means that i obviously am returning some null pointer or a empty model.
So the question arrises, how do i debug the RESTAdapter?
Upvotes: 1
Views: 224
Reputation: 9092
You seem to be using an old ember-data syntax and applying it to 1.0beta11. I don't have a link at the moment, but check on the official repository or the guides. The model
hook in your route should change from:
return App.Bodypart.find();
to
return this.store.find('bodypart');
Also you seem to be declaring your adapter incorrectly as well. It should be:
App.ApplicationAdapter = DS.RESTAdapter.extend({
host: 'http://example.com',
namespace: 'api'
});
Also, consider changing the request from the ApplicationRoute
to a child route, or you may experience "fake frozen" application as shown here
Upvotes: 3
Reputation: 1748
Regarding debugging Ember, checking the tag wiki: https://stackoverflow.com/tags/ember.js/info shows the following link: Debugging Ember
That may help.
Upvotes: 1