import React, { useState } from 'react'; import axios from 'axios'; import { useNavigate } from 'react-router-dom'; const Login = () => { const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const navigate = useNavigate(); const handleLogin = async (e) => { e.preventDefault(); try { const response = await axios.post('http://localhost:5000/login', { username, password, }); localStorage.setItem('token', response.data.token); navigate('/dashboard'); } catch (error) { console.error(error); } }; return (

Login

setUsername(e.target.value)} /> setPassword(e.target.value)} />
); }; export default Login;