Emberアプリケーションを使用してWordPressアプリケーションからデータをフェッチしようとしています。私は '2'のIDでWordPressのメニュー項目を取得しようとしています。私はember-wordpressプラグインを使用していて、投稿を正常に取得できます。私はAPIからメニューを取得するのに苦労しています。ヌルエバーのプロパティ 'id'を読み取ることができません
以下はここに私のルートである私のメニュー・モデル
import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr('string'),
count: DS.attr('number')
});
です。
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return Ember.RSVP.hash({
menu: this.store.findRecord('menu', 2)
});
}
});
私はURLをヒットしようとすると、しかし、私はここに私のコンソールに
Error while processing route: Cannot read property 'id' of null TypeError: Cannot read property 'id' of null
をエラーが発生しますが、私は私のエンドポイントから取得していJSONです。
{
"ID": 2,
"name": "Main Menu",
"slug": "main-menu",
"description": "",
"count": 2,
"items": [
{
"id": 19,
"order": 1,
"parent": 0,
"title": "Projects",
"url": "http://localhost:8888/ember-wp/projects/",
"attr": "",
"target": "",
"classes": "",
"xfn": "",
"description": "",
"object_id": 17,
"object": "page",
"object_slug": "projects",
"type": "post_type",
"type_label": "Page"
},
{
"id": 20,
"order": 2,
"parent": 0,
"title": "Services",
"url": "http://localhost:8888/ember-wp/services/",
"attr": "",
"target": "",
"classes": "",
"xfn": "",
"description": "",
"object_id": 15,
"object": "page",
"object_slug": "services",
"type": "post_type",
"type_label": "Page"
}
],
"meta": {
"links": {
"collection": "http://localhost:8888/ember-wp/wp-json/wp/v2/menus/",
"self": "http://localhost:8888/ember-wp/wp-json/wp/v2/menus/2"
}
}
}
ここでどこが間違っているのか誰にでも見られますか?