1
votes

I'm pushing ever-further into Ember and I've run into a strange issue: suddenly my Store seems to be wonky. I created a proof of concept project a while ago and everything worked fine, but now on my more robust app (which hits the same api endpoint) I'm getting much different behavior. I'm using a Django backend with Django REST Framework and rest_framework_ember (https://github.com/ngenworks/rest_framework_ember) to get the json responses in the correct format (and all that formatting looks great when I just hit the endpoint with Postman). When accessing the store in Ember, it's coming up with bupkis and using the Ember debugger I get

"Uncaught TypeError: Cannot read property 'canCatalogEntriesByType' of undefined " 

I'm running Ember 1.7.0 and EmberData 0.0.14 and here's my app.js:

App = Ember.Application.create({
    LOG_TRANSITIONS: true,
    LOG_TRANSITIONS_INTERNAL: true
});

api_location = 'http://localhost:8000';
api_namespace = 'api/v1';


App.ApplicationAdapter = DS.RESTAdapter.extend({
    host: api_location,
    namespace: api_namespace,
    headers: {
        'Content-Type': 'application/json',
        'request-source': 'ember'
    },

    ajaxError: function(jqXHR) {
        var error = this._super(jqXHR);
        if (jqXHR && jqXHR.status === 400) {
            var response = Ember.$.parseJSON(jqXHR.responseText),
            errors = {},
            keys = Ember.keys(response);
            if (keys.length === 1) {
                var jsonErrors = response[keys[0]];
                Ember.EnumerableUtils.forEach(Ember.keys(jsonErrors), function(key) {
                    errors[key] = jsonErrors[key];
                });
            }
            return new DS.InvalidError(errors);
        } else {
            return error;
        }
    }

});

App.ApplicationSerializer = DS.RESTSerializer.extend();

App.Store = DS.Store.extend({
    adapter : App.ApplicationAdapter.create()
});

I've been beating my head against the wall for a few days on this now with no progress, so any help on the subject would be amazingly helpful. Thanks in advance!

Edit: I'm also noticing that the restadapter isn't respecting the "host" that I set (trying to hit a remote endpoint to test out whether something is strange with the response)...hopefully that helps a bit.

Edit2: Getting a little further, I made Bower use ember-data 1.0.0 beta and I can control the host/namespace better and the ember inspector isn't bonking but still nothing is returned from the store.

1

1 Answers

1
votes

I ran into this same problem after upgrading an app from Ember 1.5 to 1.8.

I ended up finding this GitHub Issue, which led me to update ember-data to latest (v1.0.0-beta.11), which resolved this issue for me.

The 'Data' tab now shows again in Ember Inspector, and no longer shows the Uncaught TypeError: Cannot read property 'canCatalogEntriesByType' of undefined error.