blob: d495a8b9bc4d6cd89c3c2e6696936b2ca98fcb64 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import type { AsyncRes } from "@sortug/lib";
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}` };
}
}
|