I got a new error message that have never occurred in the past :
IntegrationBudgets.hasMany(models.integrationBudgetEntries, {
foreignKey: {
name: 'integrationBudgetIdKey',
field: 'integration_budget_id',
},
as: 'integrationBudgetIntegrationBudgetEntries',
});
router.post('/actions/ajouter-ligne-budget', permissionMiddlewareCreator.smartAction(), (request, response) => {
const data = request.body.data.attributes.values;
const integration_budget_id = request.body.data.attributes.ids[0];
const repartition_key_id = data['Clé de répartition'].split(' - ')[0];
const body = {
integration_budget_entry: {
integration_budget_id,
display_name: data['Libellé'],
repartition_key_id,
amount: data['Montant TTC'] * 100
}
};
axios.post(`${API_URL}/forest_admin/integration_budget_entries`, body, {
headers: {
'Authorization': `Bearer ${process.env.ACCESS_TOKEN}`,
'X-CURRENT-USER-EMAIL': request.user.email
},
}).then(() => {
response.send({
refresh: {
relationships: ['integrationBudgetIntegrationBudgetEntries']
}
});
}).catch(err => {
response.status(400).send({ error: err.response.data.error.message });
});
});
The error is triggered because of the “refresh” statement in the response.send.