let databox;
function initiate() {
  databox = document.getElementById("databox");

  const button = document.getElementById("button");
  button.addEventListener("click", getdata);
}
async function getdata() {
  const url = "myimage.jpg";
  try {
    const response = await fetch(url, {
      headers: {
        "Accept": "image/jpeg"
      }
    });
    if (response.ok) {
      const data = await response.blob();
      const imagedata = URL.createObjectURL(data);
      databox.innerHTML = '<img src="' + imagedata + '">';
    }
  } catch (error) {
    console.log(error);
  }
}
window.addEventListener("DOMContentLoaded", initiate);