Width 'canvas-to-blob' library you can convert base64 to blob.
import html2canvas from "html2canvas";
var toBlob = require("canvas-to-blob");
useEffect(() => {
html2canvas(document.getElementById("domEl")).then((canvas) => {
const blobImage = toBlob(canvas.toDataURL("image/png"));
return blobImage
});
}, []);
Here what I am doing is converting my dom element to Base64 with html2canvas library, then I am converting my canvas (base64) to blob using toBlob library.
If you want to send it to the server, you can use the formData constructor:
formData = formData()
formData.append('image', blobImage , 'myimage.png')
Now you can pass formData in your endpoint.!