-
Notifications
You must be signed in to change notification settings - Fork 0
/
post.html
35 lines (33 loc) · 954 Bytes
/
post.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Sparky! Go Fetch!</title>
<script>
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
brand: 'Apple',
model: 'iPhone Xs',
color: 'Space Gray'
})
};
fetch('https://httpbin.org/anything', options)
.then(response => {
if (response.ok) {
return response.json();
}
return Promise.reject(response.status);
})
.then(data => console.log(data))
.catch(error => console.log(error));
</script>
</head>
<body>
</body>
</html>