Skip to content

Instantly share code, notes, and snippets.

@eai04191
Last active August 1, 2022 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eai04191/b6cff0b367a0e1fad1430cd72bc40005 to your computer and use it in GitHub Desktop.
Save eai04191/b6cff0b367a0e1fad1430cd72bc40005 to your computer and use it in GitHub Desktop.
const host = `https://stellaria.network`;
const token = `paste your token here`;
document.querySelectorAll(".note").forEach((n) => {
const el = document.createElement("button");
el.innerText = "DELETE";
el.onclick = async (e) => {
const id = e.target
.closest(".note")
.getAttribute("data-id")
.match(/\d+$/)[0];
const cancel = !confirm(`DELETE ${id} ?`);
if (cancel) return;
await fetch(`${host}/api/v1/statuses/${id}`, {
method: "DELETE",
headers: { Authorization: `Bearer ${token}` },
});
e.target.innerText = "DELETED";
};
n.querySelector(".info").appendChild(el);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment