safeFetch overview

Added in v1.0.0


Table of contents


utils

FetchError (type alias)

Signature

export type FetchError = Error

Added in v1.2.0

Something went wrong with the fetch request and was unable to reach the server.

ServerError (type alias)

Signature

export type ServerError = Response

Added in v1.2.0

A server error response with a status and statusText.

safeFetch

Wraps fetch in a TaskEither.tryCatch.

Signature

export default function safeFetch(
  input: RequestInfo | URL,
  init?: RequestInit | undefined
): TaskEither<ServerError | FetchError, Response>

Example

import { safeFetch } from '@jvlk/fp-ts-fetch'

safeFetch('testing.com')

Added in v1.0.0