frontend performance, rpc/rest jwt authentication

This commit is contained in:
2023-06-22 11:31:24 +02:00
parent 78c1559e84
commit d6c0646756
24 changed files with 691 additions and 360 deletions

View File

@@ -0,0 +1,21 @@
import * as E from 'fp-ts/Either'
import { pipe } from 'fp-ts/function'
type FetchInit = {
url: string,
opt?: RequestInit
}
export async function ffetch<T>(
url: string,
onSuccess: (res: T) => void,
onError: (err: string) => void,
opt?: RequestInit,
) {
const res = await fetch(url, opt)
if (!res.ok) {
onError(await res.text())
return
}
onSuccess(await res.json() as T)
}