async function callApi({ baseUrl, apiKey, pathname, body }) { const res = await fetch(baseUrl.replace(/\/$/, "") + pathname, { method: "POST", headers: { "Content-Type": "application/json; charset=utf-8" }, body: JSON.stringify({ ApiVersion: "1.1", ApiKey: apiKey, ...body }), }); const data = await res.json(); if (!res.ok || data.StatusCode !== 200) { throw new Error(`${pathname} failed: ${JSON.stringify(data)}`); } return data; } async function main() { const baseUrl = process.env.PLEASANTER_BASE_URL; const apiKey = process.env.PLEASANTER_API_KEY; for (const userId of [594, 593]) { const result = await callApi({ baseUrl, apiKey, pathname: `/api/users/${userId}/delete`, body: {} }); console.log(`UserId ${userId}:`, JSON.stringify(result)); } } main().catch(e => { console.error(e); process.exit(1); });