0

I need to do the following: Create an azure Function that generates a qr code, and show it on the site (with the string you receive)


const QRCode = require('qrcode');


module.exports = async function (context, req) {
    context.log('JavaScript HTTP trigger function processed a request.');
    

    if(req.query.text) { 
        let code;
        try {
            code = await QRCode.toDataURL(req.query.text);
        } catch (err) {
            context.log.error('ERROR', err);
            throw err;
        }
        if (code) {
            context.res = {
                body: code
                
            }
            
        } else {
            context.res = {
                body: "Error: QR Code rendering error",
                status: 400
            }
        }
    } else {
        context.res = {
            body: "Error: Missing query string text",
            status: 400
        }
    }
}

I'm using node, with the node -qr code library. It's generating the right qr,i'm testing with query, but it's coming like this:

URI is a base64 encoded string that represents a file 1

I want to include the image directly from the qr, in a custom webpage

blazej
  • 1,322
  • 4
  • 10
  • 19
Gb Gb Any
  • 11
  • 2
  • Just set – Robert Oct 17 '21 at 15:32
  • base64 is bigger than png. so you can conver it like that. [tutorial](https://dev.to/dnature/convert-a-base64-data-into-an-image-in-node-js-3f88) – Robert Oct 17 '21 at 15:35
  • in parts. Within this code I need to "call" the html and I also don't know how to do this in this structure of the azure function. But thanks guys! – Gb Gb Any Oct 17 '21 at 21:27

0 Answers0