-
Notifications
You must be signed in to change notification settings - Fork 0
/
futureRef.txt
62 lines (50 loc) · 2.24 KB
/
futureRef.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React from "react";
import {useForm} from 'react-hook-form'
function SignUp() {
// const [name, setName] = useState('');
const { register, handleSubmit, formState: { error } } = useForm();
// const submitData = async input => {
// }
const onSubmit = async data => {
const requestOptions = {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: data
};
console.log(data)
await fetch('127.0.0.1:3000/api/v1/spelling/users/signup', requestOptions).then(response => response.json())
}
return (
<div>
<form onSubmit={handleSubmit(onSubmit)}>
<label htmlFor="name">Name </label>
<input id="name" {...register('name', { required: 'Name is required' })}></input>
<label htmlFor="role">Role </label>
<input id="role" {...register('role', { required: 'User role is required' })}></input>
<label htmlFor="username">Username </label>
<input id="username" {...register('username', {
required: 'Username is required',
minLength: {
value: 5,
message: 'Username should 5 character long'
}
})}></input>
<label htmlFor="password">Password </label>
<input id="password" {...register('password', {
required: 'Password is required',
minLength: {
value: 6,
message: 'Password should 5 character long'
}
})}></input>
<label htmlFor="school">School </label>
<input id="email" {...register('shool', { required: 'Your School name is required' })}></input>
<label htmlFor="email">Your Email </label>
<input id="email" {...register('email', { required: 'Email is required' })}></input>
<label htmlFor="submit">Your Email </label>
<input type="Submit" id="submit" ></input>
</form>
</div>
)
}
export default SignUp;