fixup error info

This commit is contained in:
oiov
2024-10-30 15:36:27 +08:00
parent 7b5ffb529d
commit 276575dadd
3 changed files with 15 additions and 12 deletions
@@ -74,7 +74,7 @@ export default function MetaScraping({
`/api/scraping/meta?url=${protocol}${currentLink}&key=${user.apiKey}`,
);
if (!res.ok || res.status !== 200) {
toast.error(res.statusText || "Error");
toast.error(res.statusText || "Something went wrong");
} else {
const data = await res.json();
setMetaInfo(data);
@@ -90,7 +90,8 @@ export default function MetaScraping({
const payload = `/api/scraping/screenshot?url=${protocol}${currentScreenshotLink}&key=${user.apiKey}`;
const res = await fetch(payload);
if (!res.ok || res.status !== 200) {
toast.error(res.statusText);
console.log(res);
toast.error(res.statusText || "Something went wrong");
} else {
const blob = await res.blob();
const imageUrl = URL.createObjectURL(blob);
+6 -5
View File
@@ -22,11 +22,11 @@ export async function GET(req: Request) {
const custom_apiKey = url.searchParams.get("key");
if (!custom_apiKey) {
return Response.json(
"API key is required. You can get your API key from your Dashboard-Settings.",
"API key is required. You can get your API key from Dashboard->Settings.",
{
status: 400,
statusText:
"API key is required. You can get your API key from your Dashboard-Settings.",
"API key is required. You can get your API key from Dashboard->Settings.",
},
);
}
@@ -34,9 +34,10 @@ export async function GET(req: Request) {
// Check if the API key is valid
const user_apiKey = await checkApiKey(custom_apiKey);
if (!user_apiKey?.id) {
return Response.json("Invalid API key", {
status: 403,
statusText: "Invalid API key",
return Response.json("error", {
status: 401,
statusText:
"Invalid API key. You can get your API key from Dashboard->Settings.",
});
}
+6 -5
View File
@@ -34,11 +34,11 @@ export async function GET(req: Request) {
const custom_apiKey = url.searchParams.get("key");
if (!custom_apiKey) {
return Response.json(
"API key is required. You can get your API key from your Dashboard-Settings.",
"API key is required. You can get your API key from Dashboard->Settings.",
{
status: 400,
statusText:
"API key is required. You can get your API key from your Dashboard-Settings.",
"API key is required. You can get your API key from Dashboard->Settings.",
},
);
}
@@ -46,9 +46,10 @@ export async function GET(req: Request) {
// Check if the API key is valid
const user_apiKey = await checkApiKey(custom_apiKey);
if (!user_apiKey?.id) {
return Response.json("Invalid API key", {
status: 403,
statusText: "Invalid API key",
return Response.json("error", {
status: 401,
statusText:
"Invalid API key. You can get your API key from Dashboard->Settings.",
});
}