Added LoginForm.jsx.

This commit is contained in:
David Ball 2024-05-31 01:25:20 -04:00
parent e83b62c01e
commit 4fc4ce9d48

View File

@ -0,0 +1,27 @@
import React, { useState } from 'react';
import axios from 'axios';
const LoginForm = () => {
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
const handleSubmit = async (e) => {
e.preventDefault();
try {
const response = await axios.post('/api/auth/login', { username, password });
//handle successful login
} catch (error) {
//handle login error
}
};
return (
<form onSubmit={handleSubmit}>
<input type="text" value={username} onChange={(e) => setUsername(e.target.value)} placeholder="Username" />
<input type="password" value={password} onChange={(e) => setPassword(e.target.value)} placeholder="Password" />
<button type="submit">Login</button>
</form>
);
};
export default LoginForm;