mirage ember attributes are undefined

442 views Asked by At

I'd like to use mirage with ember to simulate my api backend. I've followed the quick start and can get 10 entries via a call to the store:

return this.get('store').findAll('authors')

I've using createList to set this up, but when I view them only the id and type are correct. I can see the attribute names in ember chrome add on but everything is undefined.

Any idea what I'm doing wrong?

I thought it might be something to do with the serialiser which is:

import { JSONAPISerializer } from 'ember-cli-mirage';

export default JSONAPISerializer.extend({
});

I believe the attributes are normally in the data attribute and that is handled by ember data so it shouldn't need any further changes right?

1

There are 1 answers

0
Walter White On

Finally worked it out, under default.js for mirage I had:

server.createList('authors', 10);

Which creates my list of authors but it should be 'author' or it creates the list and then looks for the matching 'authors' factory instead of the 'author' factory and as there isn't one it just creates records with no attributes. The rest maps back to author the other side so not obvious (I hope!). Silly mistake but hopefully it will help someone else out!