samedi 27 juin 2015

Getting Django API data with Ember

I'm starting a project working with ember.js with Django Rest Framework for my REST Server.

I'm using an adapter on the ember side to get the data into the right format that Ember needs. I'm at the point where I'm making a request to my server, and getting a 200 with data returning, however Ember is throwing an error Error while processing route: index Assertion Failed: The response from a findAll must be an Array, not undefined.

There are quite a few posts about this error, but I haven't been able to find any that are relevant to my problem, it seems to be a sort of blanket error that can be caused by many things?

I'm at a loss because my server is receiving the request and returning data in the format that I would expect from the server. I'm not sure how to tell if the error is within my Ember app or if my data is not being transformed correctly by the adapter.

// routers/index.js
export default Ember.Route.extend({
  model: function() {
    return this.store.find('user');
  }
});

// config/environment.js
APP: {
  API_NAMESPACE: 'v1',
  ENV.APP.API_HOST = 'http://localhost:8000',
},

Just having this code in my router is how I get the error. I feel like this is a very simple problem, but can't seem to get past it. I've tried moving that code into different parts such as the controller, just to see that I can fetch data. Hopefully someone has a suggestion, thanks. Let me know anything else I can post to help.




Aucun commentaire:

Enregistrer un commentaire