Hi All,
I’ve created a new Ember project and I’m using Ember Data. I’ve setup Mirage as a “mock server” and created two routes:
/boards – top level /boards/board – nested
My router map looks like this:
Router.map(function() {
this.route('boards', function() {
this.route('board', { path: ':board_id' });
});
});
With Mirage, I’ve setup some routes as follows (note, I’m not sure whether “resource” means that all CRUD operations don’t need to be explicitly defined, or whether I need to define GET, POST, PATCH etc. as needed):
this.resource('boards');
this.resource('boards/:board_id');
I setup a Factory for “board” and then seeded 5 boards in a default scenario. That part worked!
In my boards template I just iterate through each of the boards and display them. I also create a LinkTo to link to the selected board. All of that works. When I navigate to a specific board, its details are displayed. I can see in Chrome that the Mirage GET is being retrieved successfully, BUT after the data returns and the template renders successfully I receive a console error:
Uncaught (in promise)
Error: Ember Data Request GET /boards/1 returned a 500 Payload (application/json) [object Object] (http://localhost:4200/assets/vendor.js:56672:16)
-- I'm using PODS structure
-- app/pods/boards/board/route.js
import Route from '@ember/routing/route';
export default class BoardsBoardRoute extends Route {
model( params ) {
return this.store.findRecord('board', params.board_id);
}
}
I’m figuring that there is probably something small that I’m not doing right here. I had originally set up all of the findAll and findRecord calls as asynchronous but I changed them to synchronous hoping to solve the problem.
Any help or guidance would be much appreciated,
Dave