diff --git a/Frontend/src/components/Login.js b/Frontend/src/components/Login.js index 7dff01c..f72eec3 100644 --- a/Frontend/src/components/Login.js +++ b/Frontend/src/components/Login.js @@ -32,15 +32,23 @@ class Login extends Component { // 123Abc!& login() { - fetch("/login", { method: "POST", body: JSON.stringify(this.state) }) - .then(function(response) { - if (response.status === 200) return response.json(); - else return response.statusText; - }) - .then(function(myJson) { - console.log(myJson); - //document.cookie = myJson; + if (this.state.username !== "" && this.state.password !== "") { + var formData = new URLSearchParams(); + formData.append("username", this.state.username); + formData.append("password", this.state.password); + fetch("https://local.tobi.one/eva/login", { + method: "POST", + body: formData, + headers: { + "content-type": "application/x-www-form-urlencoded;charset=UTF-8" + } + }).then(response => { + if (response.status === 200) { + console.log("Logged in!"); + this.props.history.push("/"); + } else console.log(response.statusText); }); + } } render() {