I am trying to convert a piece of HTML into an image using the package HTML to Image
getHTML(id) {
    htmlToImage.toJpeg(document.getElementById(id))
        .then(function (dataURL) {
            console.log(dataURL)
            return dataURL
        });
}
The problem
When I try console.log(dataURL) from within the getHTML function it runs fine but when i try console.log(this.getHTML('cardFront')) it returns undefined
