Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 19, 2020 18:02
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/d22dd743378c7dd0291affca86f5cbd4 to your computer and use it in GitHub Desktop.
Save parzibyte/d22dd743378c7dd0291affca86f5cbd4 to your computer and use it in GitHub Desktop.
async eliminar() {
const resultado = await Swal.fire({
title: 'Confirmación',
text: `¿Eliminar "${this.props.videojuego.nombre}"?`,
icon: 'question',
showCancelButton: true,
confirmButtonColor: '#3298dc',
cancelButtonColor: '#f14668',
cancelButtonText: 'No',
confirmButtonText: 'Sí, eliminar'
});
// Si no confirma, detenemos la función
if (!resultado.value) {
return;
}
const respuesta = await fetch(`${Constantes.RUTA_API}/eliminar_videojuego.php?id=${this.props.videojuego.id}`, {
method: "DELETE",
});
const exitoso = await respuesta.json();
if (exitoso) {
toast('Videojuego eliminado ', {
position: "top-left",
autoClose: 2000,
hideProgressBar: false,
closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: undefined,
});
this.setState({
eliminado: true,
});
} else {
toast.error("Error eliminando. Intenta de nuevo");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment