I\'m working with HTMLCanvas
element that return the blob object outside of the async toBlob()
function. This function doesn\'t return an output va
You can use Promise
constructor, pass Blob
instance to resolve()
, access Promise
value at .then()
function getCanvasBlob(canvas) {
return new Promise(function(resolve, reject) {
canvas.toBlob(function(blob) {
resolve(blob)
})
})
}
var canvasBlob = getCanvasBlob(canvas);
canvasBlob.then(function(blob) {
// do stuff with blob
}, function(err) {
console.log(err)
});