Hey Forest!
I’ve overriden the default put route on a table and would like to return a custom error message similar to that of a smart action. However I get this message instead. I get the correct message in the network response.
What can I do to fix this issue? Thank you in advance!
router.put('/subscriptions/:recordId', permissionMiddlewareCreator.update(), async (request, response, next) => {
const { body, params, query, user } = request;
const recordUpdater = new RecordUpdater(subscriptions, user, query);
const sub = await subscriptions.findByPk(request.params.recordId);
if(request.body.data.attributes.minChargePoints && sub.state === 'active') {
return response.status(400).send({error: 'Cannot edit min charge points once subscription is active!'});
}
recordUpdater.deserialize(body)
.then(recordToUpdate => recordUpdater.update(recordToUpdate, params.recordId))
.then(record => recordUpdater.serialize(record))
.then(recordSerialized => response.send(recordSerialized))
.catch(next);
});