Skip to content

Commit e19cc24

Browse files
authored
Update index.ts
1 parent bb3d029 commit e19cc24

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

api/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { NowRequest, NowResponse } from '@vercel/node'
22
import { getScreenshot } from './_lib/chromium';
33

44
module.exports = async (req: NowRequest, res: NowResponse) => {
5+
if (!req.query.url) return res.json({
6+
"success": false,
7+
"error": "No url query specified!",
8+
"usage": "https://screenshot.totallyusefulapi.ml/api?url=https://totallyusefulapi.ml&width=930&height=625"
9+
});
510
try {
611
const file = await getScreenshot(req.query.url, req.query.width, req.query.height);
712
res.setHeader('Content-Type', `image/png`);
@@ -11,8 +16,8 @@ module.exports = async (req: NowRequest, res: NowResponse) => {
1116
res.setHeader('Content-Type', 'application/json');
1217
res.json({
1318
"success": false,
14-
"error": "No url query",
15-
"usage": "https://screenshot.totallyusefulapi.ml/api?url=https://totallyusefulapi.ml&width=1920&height=180"
19+
"error": "Invalid url query!",
20+
"usage": "https://screenshot.totallyusefulapi.ml/api?url=https://totallyusefulapi.ml&width=930&height=625"
1621
});
1722
}
1823
}

0 commit comments

Comments
 (0)