Sending binary data and loading into an image
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Binary Data</title>
</head>
<body>
<h1>Binary Data</h1>
<img id="result" />
<script>
async function fetchImage() {
const url = 'logo.png';
const response = await fetch(url);
const blob = await response.blob();
// add returned url to image element
const img = document.getElementById('result');
img.src = URL.createObjectURL(blob);
}
fetchImage();
</script>
</body>
</html>