You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
978 B
37 lines
978 B
<script> |
|
function getAPI(){ |
|
|
|
fetch('http://localhost:3001/restricted') |
|
|
|
.then(function (res){ |
|
res.json().then(function(data){ |
|
document.getElementById('output').innerHTML = JSON.stringify(data) |
|
console.log(JSON.stringify(data)) |
|
console.log(JSON.stringify(data, ['message'])) |
|
console.log('why, though') |
|
console.log(Object.values(data)) |
|
console.log(Object.keys(data)) |
|
console.log(res.headers) |
|
}) |
|
}) |
|
|
|
} |
|
</script> |
|
<html> |
|
<head> |
|
<meta charset="utf-8"> |
|
<meta name="viewport" content="width=device-width"> |
|
<title>JS Bin</title> |
|
</head> |
|
<body onload="getAPI()"> |
|
<h1>HTML calling REST API</h1> |
|
<div id="output"></div> |
|
<div> |
|
<button type="button" |
|
onclick="document.getElementById('here').innerHTML=location.hostname"> |
|
HOSTNAME |
|
</button> |
|
<p id="here"></p> |
|
</div> |
|
</body> |
|
</html> |