I've successfully build out my app to have a proper child route and it works as it should when the user navigates through the site, but on load straight to the show route (exhibitions/slug) ember data seems to break; however, I'm still getting the proper response from the API. Here is my code, hope it makes sense..
routes/exhibitions
import Route from '@ember/routing/route';
const { set } = Ember;
export default Route.extend({
model() {
return this.store.findAll('exhibition');
},
setupController(controller, model) {
set(controller, 'exhibitions', model);
}
});
routes/exhibition
import Route from '@ember/routing/route';
const { set } = Ember;
export default Route.extend({
model() {
return this.store.findAll('exhibition');
},
setupController(controller, model) {
set(controller, 'exhibitions', model);
}
});
model for exhibition
import Contentful from 'ember-data-contentful/models/contentful';
import attr from 'ember-data/attr';
import { belongsTo, hasMany } from 'ember-data/relationships';
export default Contentful.extend({
title: attr('string'),
body: attr('string'),
slug: attr('string')
});
router.js
import EmberRouter from '@ember/routing/router';
import config from './config/environment';
const Router = EmberRouter.extend({
location: config.locationType,
rootURL: config.rootURL
});
Router.map(function() {
this.route('homepage', { path: '/' });
this.route('exhibitions');
this.route('exhibition', { path: 'exhibitions/:exhibition_slug'});
});
export default Router;
The error I'm getting in the console is:
Error while processing route: exhibition Cannot read property 'Entry' of undefined TypeError: Cannot read property 'Entry' of undefined
Let me know if anything else is needed!! Thank you!
Aucun commentaire:
Enregistrer un commentaire