I am attempting to create an Ember application that will act as a front end that fetches data from a WordPress application using the add on ember-wordpress.
I have installed the WP Menu API plugin within WordPress that gives me an end point I can query to fetch menu data in WordPress.
I have created a model for my menu
import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr('string'),
count: DS.attr('number'),
items: DS.hasMany('item')
});
And an item model
import DS from 'ember-data';
export default DS.Model.extend({
title: DS.attr('string')
});
And here is my route.
import Ember from ‘ember’;
export default Ember.Route.extend({
model() {
return this.store.findRecord('menu', 2);
}
});
Here is the JSON that my API is bringing back.
I get the error in my console:
Cannot read property ‘create’ of undefined
When I try loop over the items. It works fine when I remove the items model and I can access the menu name etc. I want to be able to store the items in an array and then loop over them in my template.