const qrcode = require('qrcode'); function convertTextToQR(text) { /** * This function takes a string as input and returns a QR code image as a base64-encoded string. * * @param {string} text - The text to be converted to QR code * @returns {string} - The base64-encoded QR code image */ try { // Generate the QR code image as a data URL const dataUrl = await qrcode.toDataURL(text); // Extract the base64-encoded image data from the data URL const base64Image = dataUrl.split(',')[1]; // Return the base64-encoded image data return base64Image; } catch (error) { // Log the error console.error(error); // Return an empty string return ''; } }