-
-
Save parzibyte/12006006865253e6f0e0766457bc1e8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`, { | |
method: "POST", | |
body: cargaUtil, | |
headers: { | |
"Content-Type":"application/json", | |
} | |
}); | |
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, | |
}); | |
this.setState({ | |
videojuego: { | |
nombre: "", | |
precio: "", | |
calificacion: "", | |
} | |
}); | |
} 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