ItSolutionStuff.com

How to Generate QR Code in Node JS?

By Hardik Savani • August 31, 2021
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...

Tags: Node JS
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Send Email using Gmail Account in Node.js?

Read Now →

How to Get Current Date and Time in Node JS?

Read Now →

How to Get Client IP Address in Node JS?

Read Now →

How to Render HTML File in Node JS Express?

Read Now →

How to Create Separate Routes File in Node JS Express?

Read Now →

How to Generate 4,6,8,10 Digit Random number in Node JS?

Read Now →

Node JS Sort Array of Objects by Value Example

Read Now →

Node JS Http Request with Headers Example

Read Now →

Node JS Make HTTP Put Request Example

Read Now →

Node JS Make HTTP Delete Request Example

Read Now →

Node JS Express Form Submission Example

Read Now →

Node JS Mysql Connection Example

Read Now →