Skip to content

Instantly share code, notes, and snippets.

@Aqua-4
Created July 14, 2020 12:05
Show Gist options
  • Save Aqua-4/7fcc25c4892a939ae84aae6d0add81b2 to your computer and use it in GitHub Desktop.
Save Aqua-4/7fcc25c4892a939ae84aae6d0add81b2 to your computer and use it in GitHub Desktop.
Chaining Promises
let tmp = ["#chart_placeholder_0", "#prod_fill_weight_placeholder"]
Promise.all(tmp.map(d => html2canvas(document.querySelector(d))))
.then(function (images) {
_.each(images, (canvas, idx) => {
img.file(`${idx}.png`, canvas.toDataURL("image/png", [0.0, 1.0]).split(',')[1], { base64: true });
})
// after
zip.generateAsync({ type: "blob" }).then(function (content) {
saveAs(content, "example.zip");
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment