1
votes

I have a problem displaying model data inside the template. Here's my code:

  1. /routes/index.js
import Ember from 'ember';

export default Ember.Route.extend({
    model() {
        return this.store.find('video');
    }
});
  1. /adapters/application.js
import DS from 'ember-data';

export default DS.JSONAPIAdapter.extend({
    defaultSerializer: 'JSONSerializer'
});
  1. /serializers/application.js
import DS from 'ember-data';

export default DS.JSONSerializer.extend({});
  1. /templates/index.hbs
{{#each video in model}}
    <p>{{video.title}}</p>
{{/each}}

however the data is not shown. I have checked the response from the server and it's a valid jsonapi.org format response. I tested by returning an Ember.Object from /router/index.js:model() and the data renders just fine. I'm confused why ember can't access the data from the store when I have specified to use JSONSerializer but renders when data returns as an array of objects. Any ideas?

UPDATE If I log {{log model}} in template, I get the following output: Class {store: Class, isLoaded: true, manager: Class, isUpdating: false, __ember1448322947671: null…}

1
Any errors in the console? - user663031
@torazaburo no errors at all. - Andrei Stalbe
Ember versions? Can you try this.store.query? - user663031
@torazaburo I have just fixed this, was in the middle of posting an answer. The problem was I used JSONSerializer instead of JSONAPISerializer - Andrei Stalbe

1 Answers

1
votes

I have figured it out. Looks like Ember changed the serializer name, it should be JSONAPISerializer instead of JSONSerializer