How to Generate QR Code in Node JS?
In this tutorial we will go over the demonstration of how to generate qr code in node js. This article goes in detailed on node.js generate qr code. we will help you to give example of generate qr code in node js. i would like to show you node qr code generator.
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.
so let's follow simple step to send mail with node js.
Step 1: Create Node App
run bellow command and create node app.
mkdir my-app
cd my-app
npm init
Step 2: Install qrcode
run bellow command and install qrcode npm package.
npm install qrcode -S
Step 3: Create server.js file
server.js
const qr = require('qrcode');
let data = {
id: 1,
name: "User",
email: "user@gmail.com"
};
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)
})
now you can simply run by following command:
node server.js
Output:
i hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Send Email using Gmail Account in Node.js?
- How to Get Current Date and Time in Node JS?
- How to Get Client IP Address in Node JS?
- How to Render HTML File in Node JS Express?
- How to Create Separate Routes File in Node JS Express?
- How to Generate 4,6,8,10 Digit Random number in Node JS?
- Node JS Sort Array of Objects by Value Example
- Node JS Http Request with Headers Example
- Node JS Make HTTP Put Request Example
- Node JS Make HTTP Delete Request Example
- Node JS Express Form Submission Example
- Node JS Mysql Connection Example