Skip to main content Link Menu Expand (external link) Document Search Copy Copied

A fetch wrapper for use with fp-ts.

Example

import fetch from 'cross-fetch'
import * as F from 'fetch-fp-ts'
import * as C from 'fp-ts/Console'
import * as RTE from 'fp-ts/ReaderTaskEither'
import { pipe } from 'fp-ts/function'

const env: F.FetchEnv = {
  fetch,
}

pipe(
  F.Request('HEAD')('foo'),
  F.send,
  RTE.chainFirstIOK(response => C.log(`Status code for ${response.url} is ${response.status}`)),
)(env)()
/*
Status code for https://www.example.com/ is 200
*/