el.xwx.moe/lib/client/fileExists.ts

10 lines
277 B
TypeScript
Raw Normal View History

2023-05-22 07:20:48 -05:00
export default async function fileExists(fileUrl: string): Promise<boolean> {
try {
const response = await fetch(fileUrl, { method: "HEAD" });
return response.ok;
} catch (error) {
console.error("Error checking file existence:", error);
return false;
}
}