Hi, I have two objects defined in my mirage config.js they look like this:
var campaigns = [
{
id: '1',
type: 'marketing',
name: 'Taylor Stitch - Back in Stock',
subject: 'The Shuttle Loomed Selvage Chambray Jack',
from: 'contact@taylorstitch.com',
preheader: 'Shuttle Loomer Selvedge Chambray Jacks are now available for immediate delivery.',
createdAt: Date.now(),
lastModified: Date.now(),
activeTemplateId: 'rebelmail-templates/multiproduct/v1',
templateSettings: templateSettings
},
];
var meta = {
page: 1,
perPage: 10,
totalPages: 1
}
Everything works fine if I return the hardcoded objects in my endpoint like this:
this.get('/campaigns', function () {
return {
campaigns,
meta
}
});
But if I create a factory for campaigns
, then I get an error no matter how I try to return both objects:
this.get('/campaigns', function (schema, request) {
return schema.campaigns.all(), meta;
});
//Assertion Failed: The response to store.query is expected to be an array but it was a single record. Please wrap your response in an array or use `store.queryRecord` to query for a single record."
I’m brand new to mirage, how can I pull of what I’m trying to achieve properly?