Untitled

mail@pastecode.io avatar
unknown
javascript
2 years ago
717 B
4
Indexable
Never
    const handleSubmit = (evt) => {
        evt.preventDefault();
        const userinfo = {
            email:	user,
            senha:	password
        }

        async function login() {
            return await fetch("http://127.0.0.1/api/users/login", {
                method: "POST",
                body: JSON.stringify(userinfo),
                headers: {
                    "Content-type": "application/json; charset=UTF-8"
                }
            });
        }
        login().then((received)=> {
            if (received.status === 200){
                setRedirectToHome(true);
            } else {
                console.log("Unauthorized")
            }
        })
    }