There may be a better way to do this, but I did it like this (minus extra bits like catch()
, etc.):
axios.get(imageUrl, { responseType:"blob" }) .then(function (response) { var reader = new window.FileReader(); reader.readAsDataURL(response.data); reader.onload = function() { var imageDataUrl = reader.result; imageElement.setAttribute("src", imageDataUrl); } });
I have a suspicion that at least part of your problem may be server-side. Even without setting { responseType: "blob" }
, you should have had something in the output of response.data
.
bjunc source share