I need to set the src
attribute of an <img>
tag using a fetch from a node server.
function fetchPicture(path) {
fetch(path)
.then(function(response) {
return response.blob();
})
.then(function(myBlob) {
return window.URL.CreateObjectURL(myBlob);
});
}
However, when handling the promise in my .then(response)
, I get a file not found exception with pathToMyHTMLFile/undefined.
My path is of the kind http://localhost:8080/Images/fig3.png
and the response is of status 200.
Any tips would be greatly appreciated!