I’ve created a smart collection :
const { collection } = require('forest-express-sequelize');
collection('sageProviders', {
fields: [{
field: 'id',
type: 'String',
get: record => record.matricule
}, {
field: 'matricule',
type: 'String',
}, {
field: 'siret',
type: 'String'
}, {
field: 'raison_sociale',
type: 'String'
}, {
field: 'site_adresse',
type: 'String'
}, {
field: 'site_ville',
type: 'String'
}, {
field: 'site_codepostal',
type: 'String'
}, {
field: 'telephone',
type: 'String'
}, {
field: 'email',
type: 'String'
}, {
field: 'bic',
type: 'String'
}, {
field: 'iban',
type: 'String'
}, {
field: 'street_number',
type: 'String'
}, {
field: 'street',
type: 'String'
}, {
field: 'domiciliation',
type: 'String'
}]
});
and its GET route :
// Get a list of sageProviders
router.get('/sageProviders', permissionMiddlewareCreator.list(), (request, response, next) => {
const recordSerializer = new RecordSerializer({ name: 'sageProviders' });
const params = {
provider_name: '',
siret: '',
matricule: ''
};
axios.get(
`${API_URL}/forest_admin/sage_providers`, {
headers: {
'Authorization': `Bearer ${process.env.ACCESS_TOKEN}`,
'X-CURRENT-USER-EMAIL': request.user.email
},
params
}).then(async res => {
response.send(await recordSerializer.serialize(res.data));
}).catch(err => {
response.status(400).send({ error: err.response.data.error.message });
});
});
The API returns literally thousands of result, so I need to fix the pagination because the table view makes my browser to crash. So far I haven’t found an explicit FA doc about how the table pagination works.