TypeScript (Deno)
Send Message via REST API
ts
const url = "https://api.pingdock.io/ping";
const body = {
dock_id: "<Dock ID>",
secret_key: "<Secret Key>",
msg: "Hello from Deno!",
};
const res = await fetch(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
console.log(await res.text());Send Message via Webhook
ts
const auth = btoa("<Dock ID>:<Secret Key>");
const payload = { msg: "Webhook from Deno!" };
const res = await fetch("https://api.pingdock.io/webhook", {
method: "POST",
headers: {
"Authorization": `Basic ${auth}`,
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
console.log(res.status, await res.text());