I am using mirage for creating fake data.
scenario/default.js
export default function(server) {
// Seed your development database using your factories. This
// data will not be loaded in your tests.
server.createList('product', 48);
server.loadFixtures();
}
Above I am creating 48 products and from controller I am calling
this.store.query('product', {
filter: {
limit: 10,
offset: 0
}
}).then((result) => {
console.log(result);
});
and in mirage/config.js
this.get('/products', function(db) {
let images = db.images;
return {
data: images.map(attrs => ({
type: 'product',
id: attrs.id,
attributes: attrs
}))
};
});
now my question is how to load 10 products per page. I am sedning in filter 10 as page size and offset means page number.
what changes should be done to config.js to load only limited products?
Aucun commentaire:
Enregistrer un commentaire