fix: 🐛 prenormalize findAll responses in application adapter

Ember Data fetch-manager will throw an error if an array resposne is an
empty object before it reaches the serializer.  Thus we need to
intercept the response in the adapter and "prenormalize" it to contain
an empty items array `{items: []}`.
This commit is contained in:
Randall Morey committed 2020-06-25 14:13:52 -04:00
1 parent e97a8ca49f
commit de8d912410
7 files changed
+120

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
export default function() {
// These comments are here to help you get started. Feel free to delete them.
/*
Config (with defaults).
Note: these only affect routes defined *after* them!
*/
// this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server
// this.namespace = ''; // make this `/api`, for example, if your API is namespaced
// this.timing = 400; // delay for each request, automatically set to 0 during testing
/*
Shorthand cheatsheet:
this.get('/posts');
this.post('/posts');
this.get('/posts/:id');
this.put('/posts/:id'); // or this.patch
this.del('/posts/:id');
https://www.ember-cli-mirage.com/docs/route-handlers/shorthands
*/
}
@@ -0,0 +1,9 @@
export default function(/* server */) {
/*
Seed your development database using your factories.
This data will not be loaded in your tests.
*/
// server.createList('post', 10);
}
@@ -0,0 +1,4 @@
import { JSONAPISerializer } from 'ember-cli-mirage';
export default JSONAPISerializer.extend({
});