I need to add image url as a blob using technologies like next and node as a backend.
First I try use simple way to create what I need.
const ErrorMsg = (props) => {
const image = "/logo.png";
const blob = new Blob([image], {type: 'image/png'})
const img = URL.createObjectURL(blob);
return (
<>
<div className={classes.errorMsg}>
<img src={img} />
</div>
</>
)
}
First time I don't know how but it works like in here image not showing but also webpack not give an error.
I forget how I it breaked but I got this error after I use some code manipulations trying to fix it.
Blob is not defined.
I thought need an extra package so I install node-blob
import Blob from "node-blob";
const ErrorMsg = (props) => {
const image = "/logo.png";
const blob = new Blob([image], {type: 'image/png'})
const img = URL.createObjectURL(blob);
return (
<>
<div className={classes.errorMsg}>
<img src={img} />
</div>
</>
)
}
So now I getting this error URL.createObjectURL is not a function