code refactoring
This commit is contained in:
@@ -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')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user