JavaScript · Track 8 · Tutorial 2 of 4
Get told when a load finishes
Let BrizoConsol tell your system when each write has finished, instead of your system asking.
You will needThe monthly script from Put the steps in order, and a public address your system listens on.
By the endA run that tells your system as each write finishes.
1When a webhook helps
Instead of reading each request back, your system can be told when a write has finished. Add webhook_url to the declarations, and BrizoConsol posts the request's status there once - when it's written, or if it fails.
2Add it to the run
monthly.mjs already adds it when BRIZO_WEBHOOK_URL is set:
monthly.mjs
function declarations(source, period, currency, webhook) {
const declarations = {
source_reference: source,
period,
value_basis: 'company_base',
rate_direction: 'document_to_base',
base_currency: currency,
};
if (webhook !== null) {
declarations.webhook_url = webhook;
}
return declarations;
}3What arrives
A POST with the same body GET …/requests/{id} answers: the counts, any refusals, and recalculation. For a trial balance that reads pending, because the call comes when the write finishes - the consolidation is still to run.
4The rules
- The address must be public: an internal or private address isn't called.
- Redirects aren't followed.
- A call that fails is recorded on the request and never fails it - read the request back to see what happened.
Want more detail? See the documentation