JavaScript

Core Javascript Example

Follwing is the complete working code for generating QR code of UPI ID using core JavaScript.

 
// Import the package
import generateQR from "@omkarbhosale/upiqr";
 
// Async funtion is required to generate the QR and retrun the promise as Base64 URL
 
const qrData = async () => {
    try {
        // Get the Base64 string by using generateQR() function.
        // UPI_ID accepts the UPI ID where to recive money in
        // AMOUNT must be an integer or float.
        
        let data = await generateQR({ UPI_ID: "omkar@upi", AMOUNT: 1234 });
        
        // The above code will generate and return the Base64 Code
        console.log(data);
    } catch (error) {
        console.error('Error generating QR code:', error);
    }
};
 
qrData();