Javascript Fetch API Tutorial - Get Request
https://mindsit.net/call-a-rest-web-service-in-javascript-using-fetch-api
by Sinh Nguyen
HTML
<button onclick="callWs()">
Click
</button>
<br/>
<b>Response Status :</b>
<div id="result">
</div>
<br/>
<b>JSON Object :</b>
<div id="result_json">
</div>
JavaScript
callWs = function(){
// The Endpoint URL
let url = 'https://sw-hcm-2.vngcloud.vn/v1/AUTH_caab399529764e80b6741fdb975ea56b/vcloudcam-ai/3rd/147/b375ae54-546e-461d-b9c6-6d666bf1366e.jgp';
console.log(url);
fetch(url)
.then(function(response) {
console.log(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);
})
}