-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
69 lines (64 loc) · 1.92 KB
/
index.html
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
63
64
65
66
67
68
69
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTTP 요청 예제</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
}
h1 {
color: #333;
margin-bottom: 20px;
}
button {
background-color: #4CAF50;
color: white;
border: none;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
border-radius: 8px;
transition: background-color 0.3s;
}
button:hover {
background-color: #45a049;
}
</style>
<script>
async function sendRequest(method) {
const url = 'https://example.com/api'; // 요청을 보낼 URL
try {
const response = await fetch(url, {
method: method,
headers: {
'Content-Type': 'application/json',
},
body: method !== 'GET' ? JSON.stringify({ key: 'value' }) : null,
});
const result = await response.json();
console.log('Response:', result);
} catch (error) {
console.error('Error:', error);
}
}
</script>
</head>
<body>
<h1>HTTP 요청 예제</h1>
<button onclick="sendRequest('GET')">GET</button>
<button onclick="sendRequest('POST')">POST</button>
<button onclick="sendRequest('DELETE')">DELETE</button>
</body>
</html>