fixup: error statu text
This commit is contained in:
@@ -74,7 +74,8 @@ export default function MetaScraping({
|
||||
`/api/scraping/meta?url=${protocol}${currentLink}&key=${user.apiKey}`,
|
||||
);
|
||||
if (!res.ok || res.status !== 200) {
|
||||
toast.error(res.statusText || "Something went wrong");
|
||||
const data = await res.json();
|
||||
toast.error(data.statusText);
|
||||
} else {
|
||||
const data = await res.json();
|
||||
setMetaInfo(data);
|
||||
@@ -89,9 +90,9 @@ export default function MetaScraping({
|
||||
setIsShoting(true);
|
||||
const payload = `/api/scraping/screenshot?url=${protocol}${currentScreenshotLink}&key=${user.apiKey}`;
|
||||
const res = await fetch(payload);
|
||||
console.log(res);
|
||||
if (!res.ok || res.status !== 200) {
|
||||
toast.error(res.statusText || "Something went wrong");
|
||||
const data = await res.json();
|
||||
toast.error(data.statusText);
|
||||
} else {
|
||||
const blob = await res.blob();
|
||||
const imageUrl = URL.createObjectURL(blob);
|
||||
|
||||
@@ -34,11 +34,13 @@ 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("error", {
|
||||
status: 401,
|
||||
statusText:
|
||||
"Invalid API key. You can get your API key from Dashboard->Settings.",
|
||||
});
|
||||
return Response.json(
|
||||
{
|
||||
statusText:
|
||||
"API key is required. You can get your API key from Dashboard->Settings.",
|
||||
},
|
||||
{ status: 401 },
|
||||
);
|
||||
}
|
||||
|
||||
const res = await fetch(link);
|
||||
|
||||
@@ -47,12 +47,11 @@ export async function GET(req: Request) {
|
||||
const user_apiKey = await checkApiKey(custom_apiKey);
|
||||
if (!user_apiKey?.id) {
|
||||
return Response.json(
|
||||
{ error: "Invalid API key" },
|
||||
{
|
||||
status: 401,
|
||||
statusText:
|
||||
"Invalid API key. You can get your API key from Dashboard->Settings.",
|
||||
"API key is required. You can get your API key from Dashboard->Settings.",
|
||||
},
|
||||
{ status: 401 },
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user