An easy way to create a QRCode on client side:

Hi,

I hope this will help someone? this creates a QRCode on the client side, it would just need to be saved or updated to a data collection or generated each time it is needed.

Si

// in client side 

import {createQRcode} from 'backend/yourFileName.jsw';

function genQR() {
 let publicKey = $w("#publicKey").value;
    createQRcode(publicKey).then(function (qrcode) {
        $w("#vectorImage1").src = qrcode;
 return qrcode;
    })
}
//in a backend JSW file
 
import QRCode from 'qrcode';

export function createQRcode(publicKey) {
 let Key = publicKey;
 let opts = {
        errorCorrectionLevel: 'H',
        type: 'svg',
        rendererOpts: {
            quality: 0.3
        }
    }
 return QRCode.toString(Key, opts, function (err, string) {
 return string;
    })
}
1 Like