OSDN Git Service

update
[projectv/server.git] / front / src / pages / account.tsx
1 import {useEffect, useState} from "react";
2 function CreateAccount () {
3  const [email, setEmail] = useState("");
4  const [password, setPassword] = useState("");
5
6      const handleSubmit = async () => {
7         const response = await fetch("/api/account", {
8             method: "POST",
9             headers: {
10                 "Content-Type": "application/json",
11             },
12             body: JSON.stringify({email, password}),
13         });
14         const data = await response.json();
15         console.log(data);
16      }
17
18      return (
19          <div>
20                 <h1>Create Account</h1>,
21              <label htmlFor="email">Email
22                  <form onSubmit={handleSubmit}>
23                      <input type="email" value={email} onChange={(e) => setEmail(e.target.value)} />
24                  </form>
25                  <form onSubmit={handleSubmit}>
26                      <input type="password" value={password} onChange={(e) => setPassword(e.target.value)} />
27                  </form>
28                  <button type="submit" >Create Account</button>
29              </label>
30          </div>
31      )
32 }
33
34 export default CreateAccount;