@mainframe/transport-create-http
v0.1.2
Published
HTTP transport factory
Downloads
13
Keywords
Readme
transport-create-http
HTTP transport factory used by transport-http-browser
and transport-http-node
.
Throws HTTPError
when the request fails.
Installation
yarn add @mainframe/transport-create-http
Usage
import createTransport from '@mainframe/transport-create-http'
const request = createTransport(window.fetch)('http://localhost')
request({ hello: 'transport' }).then(console.log)
API
createTransport() (default export)
Arguments
fetch: (req: Request) => Response
: function implementing theFetch
interfaces.
Returns (data: Object) => Promise<any>
HTTPError class
Arguments
status: number
: HTTP status codemessage: string
: error message
Properties
status: number
: HTTP status codemessage: string
: error message
License
MIT