-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-registration.html
More file actions
61 lines (56 loc) 路 1.95 KB
/
Copy pathtest-registration.html
File metadata and controls
61 lines (56 loc) 路 1.95 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test Registration</title>
</head>
<body>
<h1>Test Registration</h1>
<form id="registrationForm">
<div>
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
</div>
<div>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
</div>
<div>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
</div>
<button type="submit">Register</button>
</form>
<div id="result"></div>
<script>
document.getElementById('registrationForm').addEventListener('submit', async (e) => {
e.preventDefault();
const formData = {
name: document.getElementById('name').value,
email: document.getElementById('email').value,
password: document.getElementById('password').value
};
try {
const response = await fetch('http://localhost:3001/api/auth/register', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(formData)
});
const result = await response.json();
document.getElementById('result').innerHTML = `
<h3>Response:</h3>
<pre>${JSON.stringify(result, null, 2)}</pre>
`;
} catch (error) {
document.getElementById('result').innerHTML = `
<h3>Error:</h3>
<pre>${error.message}</pre>
`;
}
});
</script>
</body>
</html>