Converting the QR code to image

  1. Get QR Code:

    Get the qr_code from the API response.

  2. Basic Decode:

    Decode the qr_code data (which is encoded using Base64 encoding).

    Example: In JS,

    const decodedQrCode = window.atob(qr_code);
    
  3. Convert to QR Image URL:

    Use any known internal method of your programming language or use an external library to convert decodedQrCode to QR image URL.

    Example: qrcode npm package, sample code block as per the npm package readme doc,

    For ES6/ES7

    import QRCode from 'qrcode'
    
    let **qr_url =** null;
    
    // With promises
    QRCode.toDataURL(decodedQrCode)
      .then((url) => {
        console.log(url)
    		**qr_url** = url;
      })
      .catch((err) => {
        console.error(err)
      })
    
  4. Render QR Image:

    set the qr_url in the src attribute of image element in HTML.

    Example:

    <img
    		:src="qr_url" // QR image url to render in UI.
    		class="" // add relevant styles 
    		alt="QR image"
    />