diff --git a/src/Components/Api/Api.tsx b/src/Components/Api/Api.tsx index 007e5a1..6b403f2 100644 --- a/src/Components/Api/Api.tsx +++ b/src/Components/Api/Api.tsx @@ -22,3 +22,21 @@ export function AddNote(note: note) { export function DeleteNote(id: number) { return axios.delete("http://localhost:8000/api/v1/notes/" + id + "/"); } + +export interface user { + username: string; + password: string; +} + +export function UserLogin(user: user) { + return axios + .post("http://localhost:8000/api/v1/accounts/token/login", user) + .then((response) => { + console.log("Success! Token: " + response.data); + return true; + }) + .catch((error) => { + console.log("Login Failed: " + error); + return false; + }); +} diff --git a/src/Routes/Login/Login.tsx b/src/Routes/Login/Login.tsx index e12b6c6..597009f 100644 --- a/src/Routes/Login/Login.tsx +++ b/src/Routes/Login/Login.tsx @@ -5,6 +5,7 @@ import { useLocation, useNavigate } from "react-router-dom"; import Header from "../../Components/Header/Header"; import { useState } from "react"; import { Button } from "@mui/material"; +import { UserLogin } from "../../Components/Api/Api"; export default function Login() { const navigate = useNavigate(); @@ -12,7 +13,8 @@ export default function Login() { username: "", password: "", }); - console.log("We are in the" + useLocation()); + const [error, setError] = useState(""); + return (
{error}