blob: 1c403556401c03c0eb0b90a6c418f761c84a4a00 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import type { AsyncRes } from "sortug";
export async function ocr(formData: FormData): AsyncRes<string[]> {
const endpoint = "http://localhost:8102/ocr";
const opts = {
method: "POST",
body: formData,
headers: { "X-API-KEY": Bun.env.SORTUG_NLP_API_KEY! },
};
try {
const res = await fetch(endpoint, opts);
const j = await res.json();
return { ok: j };
} catch (e) {
return { error: `${e}` };
}
}
|