Javascript Fetch API Tutorial - Get Request
https://mindsit.net/call-a-rest-web-service-in-javascript-using-fetch-api
by rowntreerob
HTML
<button onclick="callWs()">
Click
</button>
<br/>
<b>Response Status :</b>
<input type="hidden" name="region" value="us-east-1">
<input type="hidden" name="bucket" value="MyBucketName">
<input type="hidden" name="folder" value="MyFolder">
<input type="hidden" name="AWSAccessKeyId" value= "myAWS Key" >
<input type="hidden" name="AWSSecretKey" value="myAWS Secret">
<input type="hidden" name="token" value="Bearer $access-token">
JavaScript
callWs = function(){
// The Endpoint URL
let url = 'https://jsonplaceholder.typicode.com/posts/1';
fetch(url)
.then(function(response) {
// Render the Response Status
document.getElementById('result').innerHTML = response.status;
// Parse the body as JSON
return response.json();
})
.then(function(json) {
// Render the parsed body
document.getElementById('result_json').innerHTML = JSON.stringify(json);
})
}