Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4828

Cannot read property 'create' of undefined

$
0
0

@pocockn wrote:

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.

https://pastebin.com/15Q3kh0B

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.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4828

Trending Articles