Untitled
unknown
javascript
3 years ago
888 B
1
Indexable
const handleSubmit = (evt) => { evt.preventDefault(); const userinfo = { email: user, senha: password } async function login() { let response = await fetch("http://127.0.0.1/api/users/login", { method: "POST", body: JSON.stringify(userinfo), headers: { "Accept": "*/*", "Content-type": "application/json; charset=UTF-8" } }); let data = await response.json() return [response, data] } login().then((received)=> { console.log(received) if (received[0].status === 200){ setRedirectToHome(true); } else { console.log("Unauthorized") } }) }
Editor is loading...