Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 11, 2020 18:54
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 parzibyte/0d3a22e90aaca13fd8cda7f109de264f to your computer and use it in GitHub Desktop.
Save parzibyte/0d3a22e90aaca13fd8cda7f109de264f to your computer and use it in GitHub Desktop.
async deleteGame(game) {
const result = await Swal.fire({
title: 'Delete',
text: "Are you sure you want to delete this game?",
icon: 'question',
showCancelButton: true,
confirmButtonColor: '#1f9bcf',
cancelButtonColor: '#d9534f',
cancelButtonText: 'No',
confirmButtonText: 'Yes, delete it'
});
// Stop if user did not confirm
if (!result.value) {
return;
}
const r = await fetch(SERVER_URL + "/game/" + game[0], {
method: "DELETE",
});
const response = await r.json();
if (response) {
this.$toasted.show("Deleted", {
position: "top-left",
duration: 1000,
});
await this.getGames();
} else {
this.$toasted.show("Something went wrong. Try again", {
position: "top-left",
duration: 1000,
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment