Untitled

 avatar
unknown
javascript
3 years ago
717 B
4
Indexable
    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")
            }
        })
    }