File size: 493 Bytes
f710fc8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
function deletePost(postId) {
fetch(`/delete_post/${postId}`, { method: 'POST' })
.then((response) => {
if (response.ok) {
const postElement = document.querySelector(`.post[data-post-id="${postId}"]`);
if (postElement) {
postElement.remove();
}
} else {
console.error('Error deleting post:', response);
}
})
.catch((error) => {
console.error('Error deleting post:', error);
});
} |