-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
39 lines (36 loc) · 1.29 KB
/
test.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flask API Example</title>
</head>
<body>
<h1>Flask API Example</h1>
<button id="getAPI">Get API Data</button>
<div id="result"></div>
<script>
document.getElementById('getAPI').addEventListener('click', () => {
// Define the JSON data
const jsonData = {
"emailid":"[email protected]",
"linkedin":"https://www.linkedin.com/in/raaasin/","github":"https://github.com/raaasin"
};
fetch('http://192.168.9.140:5000/api/newuser', {
method: 'POST',
headers: {
'Content-Type': 'application/json' // Set the content type to JSON
},
body: JSON.stringify(jsonData) // Convert JSON object to string
})
.then(response => response.json())
.then(data => {
document.getElementById('result').innerText = JSON.stringify(data);
})
.catch(error => {
document.getElementById('result').innerText = 'Error: ' + error;
});
});
</script>
</body>
</html>