safeFetchJson overview
Added in v1.1.0
Table of contents
utils
JsonError (type alias)
Signature
export type JsonError = Error
Added in v1.2.0
The JSON returned from the server is invalid.
safeFetchJson
Safely fetch and attempt to parse the responses json.
Signature
export default function safeFetchJson<T>(
input: RequestInfo | URL,
init?: RequestInit | undefined
): TaskEither<ServerError | FetchError | JsonError, T>
Example
import { safeFetchJson } from '@jvlk/fp-ts-fetch'
safeFetchJson('api.com')() // => Either<Error, T>
Added in v1.1.0