add latest blog post to admin dashboard view
This commit is contained in:
parent
21912d4ec2
commit
fec3325503
5 changed files with 93 additions and 7 deletions
|
|
@ -0,0 +1,25 @@
|
|||
document.addEventListener('readystatechange', () => {
|
||||
const newBlogBtn = document.getElementById("create-post");
|
||||
if (newBlogBtn) newBlogBtn.addEventListener("click", event => {
|
||||
event.preventDefault();
|
||||
const id = prompt("Enter an ID for this blog post:");
|
||||
if (id == null || id == "") return;
|
||||
|
||||
fetch("/api/v1/blog", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({id})
|
||||
}).then(res => {
|
||||
if (res.ok) location = "/admin/blogs/" + id;
|
||||
else {
|
||||
res.text().then(err => {
|
||||
alert(err);
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
}).catch(err => {
|
||||
alert("Failed to create release. Check the console for details.");
|
||||
console.error(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue