Update index.js
Browse files
index.js
CHANGED
@@ -83,7 +83,7 @@ app.get('/qrcode', async (req, res) => {
|
|
83 |
});
|
84 |
} else if (['read', 'scan'].includes(mode)) {
|
85 |
// Fetch the image and read the QR code
|
86 |
-
const
|
87 |
if (!rts.ok || rts.status !== 200) return res.send({
|
88 |
status: 400,
|
89 |
message: 'Can\'t buffer url'
|
@@ -92,7 +92,7 @@ app.get('/qrcode', async (req, res) => {
|
|
92 |
status: 400,
|
93 |
message: 'Only image type'
|
94 |
})
|
95 |
-
const buffer = Buffer.from(await
|
96 |
const image = await Jimp.read(buffer);
|
97 |
|
98 |
// Preprocess the image to enhance QR code readability
|
|
|
83 |
});
|
84 |
} else if (['read', 'scan'].includes(mode)) {
|
85 |
// Fetch the image and read the QR code
|
86 |
+
const rts = await fetch(url);
|
87 |
if (!rts.ok || rts.status !== 200) return res.send({
|
88 |
status: 400,
|
89 |
message: 'Can\'t buffer url'
|
|
|
92 |
status: 400,
|
93 |
message: 'Only image type'
|
94 |
})
|
95 |
+
const buffer = Buffer.from(await rts.arrayBuffer());
|
96 |
const image = await Jimp.read(buffer);
|
97 |
|
98 |
// Preprocess the image to enhance QR code readability
|