Node.js
Node.js 18 or newer (built-in fetch), no packages.
The code
This is the code the Code tab generates (with start, errors and rows ticked). In the app it already contains your job's own address.
// --- TaskBeacon: top of the script (Node 18+, no packages) ---
const TB = "https://taskbeacon.io/ping/your-job-id";
async function tbPing(path = "", data) {
const opts = data ? { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(data) } : {};
try { await fetch(TB + path, { ...opts, signal: AbortSignal.timeout(10000) }); }
catch (e) { console.error("TaskBeacon ping failed:", e.message); }
}
async function main() {
await tbPing("/start");
let data;
try {
// --- your code here ---
data = [{ amount: 12.5 }]; // example data: replace with your rows
} catch (e) {
await tbPing("/fail", { error: `${e.name}: ${e.message}`.slice(0, 200), log: String(e.stack).split("\n").slice(-20).join("\n") });
throw e;
}
// --- TaskBeacon: end of the script ---
await tbPing("", { rows: data.length });
}
main().catch((e) => { console.error(e); process.exit(1); });How it works
The code pings /start when the script begins, the plain address with the row count when it ends well, and /fail when it fails, with the error and the last 20 lines of its stack.
Untick options on the Code tab to leave parts out; untick Send output lines to send no output, only the error or exit code. See what can be reported.
Run on a schedule
On Windows, give Task Scheduler the full path to Node, because it doesn't know your PATH (one line, in a Command Prompt):
schtasks /Create /TN "API sync" /SC DAILY /ST 04:00 /TR "\"C:\Program Files\nodejs\node.exe\" C:\jobs\sync.js"
On Linux or a Mac, one crontab line (crontab -e); which node shows the path:
0 4 * * * /usr/bin/node /home/me/jobs/sync.js
Common problems
- fetch is not defined. The code needs Node.js 18 or newer (built-in
fetch). - No ping behind a company proxy. Node's built-in
fetchignoresHTTP_PROXY/HTTPS_PROXYunless you start Node with--use-env-proxyor setNODE_USE_ENV_PROXY=1(Node 22.21 or 24.5 and newer). - A certificate error (such as
UNABLE_TO_GET_ISSUER_CERT_LOCALLY). A proxy that inspects HTTPS signs with the company's own certificate, and Node doesn't read the Windows certificate store by default. Start Node with--use-system-ca(Node 22.19 or 24.6 and newer), or setNODE_EXTRA_CA_CERTSto the company's certificate file. - Start arrives but never the finish. The script exited before
main()finished, for example withprocess.exit()inside your code. After the grace period the job shows as Late.