I used fetch for a 'get' request, but now I want to switch to axios. Can someone please help me convert this code to use axios instead?
More details: I am fetching an image and using the blob method to display it to the user. I would like to achieve the same functionality with axios.
Here is the code snippet:
const image = (url) =>
fetch(url)
.then((response) => {
return response.blob();
})
.then(
(blob) =>
new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result);
reader.onerror = reject;
reader.readAsDataURL(blob);
})
);