code refactoring

This commit is contained in:
2024-02-12 12:02:23 +01:00
parent cc06487b0a
commit 65b0c8bc0e
7 changed files with 51 additions and 32 deletions

View File

@@ -1,11 +1,13 @@
import { tryCatch } from 'fp-ts/TaskEither'
/**
* functional fetch(): composable as TaskEither
*/
export const ffetch = <T>(url: string, opt?: RequestInit) => tryCatch(
() => fetcher<T>(url, opt),
(e) => `error while fetching: ${e}`
)
const fetcher = async <T>(url: string, opt?: RequestInit) => {
const jwt = localStorage.getItem('token')