Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 19, 2020 18:14
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/68099286449c9de3ddbea8de112ceb96 to your computer and use it in GitHub Desktop.
Save parzibyte/68099286449c9de3ddbea8de112ceb96 to your computer and use it in GitHub Desktop.
async manejarEnvioDeFormulario(evento) {
evento.preventDefault();
// Codificar nuestro videojuego como JSON
const cargaUtil = JSON.stringify(this.state.videojuego);
// ¡Y enviarlo!
const respuesta = await fetch(`${Constantes.RUTA_API}/actualizar_videojuego.php`, {
method: "PUT",
body: cargaUtil,
});
const exitoso = await respuesta.json();
if (exitoso) {
toast('Videojuego guardado 🎮', {
position: "top-left",
autoClose: 2000,
hideProgressBar: false,
closeOnClick: true,
pauseOnHover: true,
draggable: true,
progress: undefined,
});
} else {
toast.error("Error guardando. Intenta de nuevo");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment