<button type = "button" onclick="loadDoc">IMAGE TEST</button>
<p id = "demo"></p>
<script>
function loadDoc(){
for (let item in Response.items) {
for (let camera in item.cameras) {
const imageUrl = camera.image;
document.getElementById("demo").innerHTML=camera.image;
}
}
xhr.open("GET","https://api.data.gov.sg/v1/transport/traffic-images",true);
xhr.send();
};
</script>
I want to extract the image from the API provided by i wasn't able to show it in the html file
Output shows:
{"items":[{"timestamp":"2018-12-20T21:59:41+08:00","cameras":[{"timestamp":"2018-12-20T21:59:21+08:00","image":"https://images.data.gov.sg/api/traffic-images/2018/12/05cd4190-b4e4-430c-b1c1-7047972c09fe.jpg","location":{"latitude":1.27414394350065,"longitude":103.851316802547},"camera_id":"1501","image_metadata":{"height":240,"width":320,"md5":"7bcfabb38b60a18f1380bffca095d6c0"}},{"timestamp":"2018-12-20T21:59:21+08:00","image":"https://images.data.gov.sg/api/traffic-images/2018/12/06c05520-98b6-4086-b691-1bb54ed90482.jpg","location":{"latitude":1.27135090682664,"longitude":103.861828440597},"camera_id":"1502","image_metadata":.....