0

私は ember アプリを構築しており、レール API に接続して、質問エンドポイントからデータを読み込もうとしています。

これらは 2 つの別個のアプリケーションです。

私のコードは次のとおりです。

アダプター/application.js

import DS from 'ember-data';
import ActiveModelAdapter from 'active-model-adapter';

export default DS.ActiveModelAdapter.extend({
  host: 'http://localhost:3000/api/v2'
});

models/questions.js

import DS from 'ember-data';

export default DS.Model.extend({
  text:  DS.attr('string'),
  title: DS.attr('string'),
  debateTopicId:  DS.attr('string'),
  releaseAt: DS.attr('date'),
  expiresAt:  DS.attr('date')
});

ルート/questions.js

import Ember from 'ember';

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

templates/questions.hbs

<h2>This is the Questions Feed</h2>

{{#each model as |question|}}
  <h3>{{question.id}} - {{question.text}}</h3>
{{/each}}

私が呼び出そうとしているエンドポイントは次のとおりです。

http://localhost:3000/api/v2/questions

エラーが発生します:

ember.debug.js:19746 Error: Failed to create an instance of 'adapter:application'. Most likely an improperly defined class or an invalid module export.
    at instantiate (ember.debug.js:1477)
    at lookup (ember.debug.js:1336)
    at Object.lookup (ember.debug.js:1255)
    at Class.lookup (ember.debug.js:34526)
    at ContainerInstanceCache.instanceFor (container-instance-cache.js:62)
    at ContainerInstanceCache._findInstance (container-instance-cache.js:51)
    at ContainerInstanceCache.get (container-instance-cache.js:39)
    at Class.retrieveManagedInstance (store.js:2105)
    at Class.lookupAdapter (store.js:2111)
    at Class.adapterFor (store.js:2051)

問題は何ですか?

4

0 に答える 0