Files
wtr/lib/imgw-empty-response.ts
zv ee55521803
All checks were successful
CI / Lint, typecheck and build (push) Successful in 9m56s
chore: add prettier formatting
2026-06-14 20:26:56 +02:00

20 lines
662 B
TypeScript

export function isImgwNoProductsResponse(value: unknown) {
if (!value || typeof value !== "object") return false;
const response = value as { status?: unknown; message?: unknown };
return (
response.status === false &&
typeof response.message === "string" &&
response.message.toLocaleLowerCase("en-US").includes("no products were found")
);
}
export async function readImgwResponseBody(response: Response) {
const text = await response.text().catch(() => "");
if (!text) return { text, json: null as unknown };
try {
return { text, json: JSON.parse(text) as unknown };
} catch {
return { text, json: null as unknown };
}
}