0
votes

Ember app, using Ember CLI, ember-data and http-mock. I can't seem to connect to the store from the clubs/index route.

enter image description here

This seems to be the offending code. If I remove the call to the store, and include an inline model everything works fine. Nop idea why it can't find the store.

// clubs/index.js

import Ember from 'ember';

export default Ember.Route.extend({
    model: function() {
        return this.store.find('club');
    }
});

The http-mock works just fine when I curl it:

curl -H "ContentType:application/json" http://localhost:4200/api/clubs

Everything else is pretty standard:

// router.js

import Ember from 'ember';
import config from './config/environment';

var Router = Ember.Router.extend({
    location: config.locationType
});

Router.map(function() {
    this.resource('clubs', function() {

    });
});

export default Router;

// club.js

import DS from 'ember-data';

export default DS.Model.extend({
    name: DS.attr('string')
});

Any help much appreciated!

1

1 Answers

3
votes

The problem looks to be that your app is hitting /clubs while your api is located at /api/clubs. To fix this you can create an ApplicationAdapter in app/adapters/application.js to properly namespace your api:

import DS from 'ember-data';

export default DS.ActiveModelAdapter.extend({
  namespace: 'api'
});