Created
May 14, 2016 13:05
-
-
Save chrism/d1c818570b545dc31e580132f7a08f0d to your computer and use it in GitHub Desktop.
Mirage hasMany belongsTo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default [ | |
{ | |
id: "e9aa15df-3893-4a46-8e02-70ae1d681af9", | |
name: "Test Name", | |
videoIds: ["436639cb-38f8-415d-afb0-04cfb3f4e33f"] | |
} | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default [ | |
{ | |
id: "436639cb-38f8-415d-afb0-04cfb3f4e33f", | |
title: "Test Title", | |
userId: "e9aa15df-3893-4a46-8e02-70ae1d681af9" | |
} | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Model, hasMany } from 'ember-cli-mirage'; | |
export default Model.extend({ | |
videos: hasMany() | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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