-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (28 loc) · 819 Bytes
/
index.js
File metadata and controls
37 lines (28 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//Use the inquirer npm package to get user input.
import inquirer from 'inquirer';
import qr from "qr-image";
import fs from "fs";
inquirer
.prompt([
{"message":"Type in your URL:",
name:"URL"}
])
.then((answers) => {
const url=answers.URL;
//generating QR
var qr_svg = qr.image(url);
qr_svg.pipe(fs.createWriteStream('qr_img.png'));
fs.writeFile('url1.txt',url, (err, data) => {
if (err) throw err;
console.log("file is saved");
});
})
.catch((error) => {
if (error.isTtyError) {
// Prompt couldn't be rendered in the current environment
} else {
// Something else went wrong
}
});
//Use the qr-image npm package to turn the user entered URL into a QR code image.
//Create a txt file to save the user input using the native fs node module.