tsayen / dom-to-image

Generates an image from a DOM node using HTML5 canvas
Other
10.21k stars 1.68k forks source link

Uncaught (in promise) #376

Open stefan-reich opened 3 years ago

stefan-reich commented 3 years ago

Yup... I got it too. No particular reason I can think of. Two images are from a foreign server - but that shouldn't break the whole process?

Screenshot

Demo

What I called:

  domtoimage.toJpeg(document.body, { quality: 0.95 })
    .then(function (dataUrl) {
        var link = document.createElement('a');
        link.download = 'gazelle-screenshot.jpg';
        link.href = dataUrl;
        link.click();
    });
stefan-reich commented 3 years ago

PS: Switched to html2canvas, works like a charm

shaikh-amaan-fm commented 3 years ago

I had this same issue when I had local images in my page (file:///) and I found this happens because a part in the library's code expects the servers response status code to be 200 on success. So as far as what I can see from the screenshot you shared, the server serving those images are not sending 200 status code instead it sent 0.

stefan-reich commented 3 years ago

Yeah the images are on a different domain and dom-to-image cannot fetch them. Maybe that's what broke the whole thing. I'm using html2canvas now BTW, it's the same as dom-to-image but in, uh, "works".

sujiangyin commented 9 months ago

had the same issue,how did you solve it?