-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
43 lines (43 loc) · 1012 Bytes
/
test.html
File metadata and controls
43 lines (43 loc) · 1012 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=#, initial-scale=1.0">
<title>Document</title>
<style>
body{
background-color: brown;
}
h1{
text-align: center;
}
button {
margin: auto;
}
</style>
</head>
<body>
<h1>hello world</h1>
<button onclick="sendData()">send data</button>
<script>
const data = {
name: 'baber',
specie: 'animal',
age: 3,
}
function sendData(){
console.log('Function is activated')
fetch('http://localhost:3000/api/sendData',{
method:'POST',
headers:{
'Content-type':'application/json',
},
body: JSON.stringify(data),
})
.then(response => response.json())
.then(response => console.log(response.message))
.catch(err => console.log('There was an Error',err))
}
</script>
</body>
</html>