In this example we will see how to generate QR Code in Node.js application. In this example we will use qrcode npm package for generate QR Code. we will create json data object and create QR Code for that json data object.
QR code has become an important part of life now a days. QR means “Quick Response”. It can store a large amount of data. QR scanner can instantly process the data by scanning it. In Node.js generate QR Code is very easy.
So, In this tutorial we are generate QR Code using qrcode package in Node.js.
In this step create node application using below commands.
mkdir qr_code_example
cd qr_code_example
npm init
In this step install the qrcode module using below command
npm install qrcode
In this step we can send emai with attachment. So, make sure your configurarion before sending email.
const qr = require('qrcode');
let data = {
id: 1,
name: "dell",
email: "[email protected]"
};
let strData = JSON.stringify(data);
qr.toString(strData, {type:'terminal'},
function (err, code) {
if(err) return console.log("error occurred !!");
console.log(code);
});
qr.toDataURL(strData, function (err, code) {
if(err) return console.log("error occurred !!");
console.log(code);
})
const data = {
errorCorrectionLevel: 'H',
type: 'terminal',
quality: 0.95,
margin: 1,
color: {
dark: '#208698',
light: '#FFF',
},
}
let strData = JSON.stringify(data)
For Custom QR Code generate you define diffrent parameters like above code.
run index.js using below code :
node index.js
You might also like :
In this post we will see how to create slider using jquery, here we will use owl carousel for create slider using b...
Aug-04-2021
In this article, we will see carbon add years to date in laravel 9. Carbon provides addYear() and addYears() functi...
Nov-21-2022
In this article, we will see how to create a dynamic line chart in laravel 9. A dynamic line chart or line plot or...
Mar-22-2022
In this example, we will see how to convert an image into a base64 string using jquery. Base64 encoding schemes are...
Jan-03-2022