Reputation: 382
I need to convert user data into a QR Code and show it in the web browser what is the best way to generate QR Code in node js and show it in user browser
Upvotes: 4
Views: 13474
Reputation: 1
You can use this url in image tag like this ->
Example of app.js
or index.js
file
var QRCode = require('qrcode');
app.get('/', function (req, res) {
QRCode.toDataURL('I am a pony!', function (err, url) {
console.log(url)
res.render('index', {qr: url});
});
});
In your template: (i am using ejs as my template engine)
<img src="<%= qr %>">
after this you will get qrcode image instead of qrcode data. i hope this would help you
Upvotes: -1