Level 104
Adapted from the SweetAlert docs:
swal({
title: "Are you sure?",
text: "Once deleted, you will not be able to recover this!",
icon: "warning",
buttons: true,
dangerMode: true,
})
.then((willDelete) => {
if (willDelete) {
axios.delete('/path/to/delete/resource')
.then((response) => {
swal("Deleted successfully!", {
icon: "success",
});
})
.catch(() => {
swal("Error!", "Failed to delete!", "error");
})
}
})
1 like