How to Generate QR Code in Node JS?

About Us:

We are from free coder. We are a group of web developers who are passionate about web development. You can learn from us php, laravel, node js, vue js, react js and many other topic on web developement.
we are very happy to help you.
free coder

Today what you are going to learn:

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 lesson of generate qr code in node js. i would like to show you node qr code generator.

In this lesson 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.

Lesson 1: Create Node App

run bellow command and create node app.

mkdir my-app

cd my-app

npm init

Lesson 2: Install qrcode

run bellow command and install qrcode npm package.

npm install qrcode -S

Lesson 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

Result:-

thank you very much for following up with me.

Tags

Recent Posts

Related Posts