Skip to content

Instantly share code, notes, and snippets.

@chrism
Created May 14, 2016 13:05
Show Gist options
  • Save chrism/d1c818570b545dc31e580132f7a08f0d to your computer and use it in GitHub Desktop.
Save chrism/d1c818570b545dc31e580132f7a08f0d to your computer and use it in GitHub Desktop.
Mirage hasMany belongsTo
export default function() {
this.get('/videos', (schema) => {
return schema.videos.all();
});
this.get('/users/:id', (schema, request) => {
const id = request.params.id;
return schema.users.find(id);
});
}
// when the request for /videos is made I get this error
// Mirage: Your handler for the url /videos threw an error: Maximum call stack size exceeded
export default [
{
id: "e9aa15df-3893-4a46-8e02-70ae1d681af9",
name: "Test Name",
videoIds: ["436639cb-38f8-415d-afb0-04cfb3f4e33f"]
}
]
export default [
{
id: "436639cb-38f8-415d-afb0-04cfb3f4e33f",
title: "Test Title",
userId: "e9aa15df-3893-4a46-8e02-70ae1d681af9"
}
]
import { Model, hasMany } from 'ember-cli-mirage';
export default Model.extend({
videos: hasMany()
});
import { Model, belongsTo } from 'ember-cli-mirage';
export default Model.extend({
user: belongsTo()
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment