Files
sistem-desa-mandiri/src/module/_global/fun/read_pdf.ts
2025-01-16 17:23:17 +08:00

22 lines
1.0 KiB
TypeScript

export async function funReadPdf({ file, page }: { file: string, page:number }) {
try {
const res = await fetch(`https://wibu-storage.wibudev.com/api/pdf-to-image?url=https://wibu-storage.wibudev.com/api/files/${file}&pages=${page}`, {
method: "GET",
headers: {
Authorization: `Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjp7ImlkIjoiY20wdnQ4bzFrMDAwMDEyenE1eXl1emd5YiIsIm5hbWUiOiJhbWFsaWEiLCJlbWFpbCI6ImFtYWxpYUBiaXAuY29tIiwiQXBpS2V5IjpbeyJpZCI6ImNtMHZ0OG8xcjAwMDIxMnpxZDVzejd3eTgiLCJuYW1lIjoiZGVmYXVsdCJ9XX0sImlhdCI6MTcyNTkzNTE5MiwiZXhwIjo0ODgxNjk1MTkyfQ.7U-HUnNBDmeq_6XXohiFZjFnh2rSzUPMHDdrUKOd7G4`
// Authorization: `Bearer ${process.env.WS_APIKEY}`
}
});
if (res.ok) {
const hasil = await res.json()
return { success: true, data: hasil }
} else {
const errorText = await res.text();
return { success: false, data: {} }
}
} catch (error) {
console.error("Upload error:", error);
return { success: false, data: {} }
}
}