I'm trying to get an image from my server without setting any of responseType: blob
or responseType: arrayBuffer
or responseType: 'stream'
,...
Here is what I tried:
axios.get('https://xxx/myapi').then(response => {
const blob = new Blob([response.data], { type: 'application/oclet-stream' });
const fileURL = URL.createObjectURL(blob);
const img = document.createElement('img');
img.src = fileURL;
document.body.appendChild(img);
});
myapi
response is a stream
that is an image.
But, the blob
response is not my image (it's something like plain text converted to Blob).
Any solution for that?