@mainframe/transport-create-http

0.1.2 • Public • Published

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

  1. fetch: (req: Request) => Response: function implementing the Fetch interfaces.

Returns (data: Object) => Promise<any>

HTTPError class

Arguments

  1. status: number: HTTP status code
  2. message: string: error message

Properties

  • status: number: HTTP status code
  • message: string: error message

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @mainframe/transport-create-http

Weekly Downloads

2

Version

0.1.2

License

MIT

Unpacked Size

6.38 kB

Total Files

7

Last publish

Collaborators

  • aclarke
  • diogoperillo
  • howleysv
  • mosic
  • paul_lecam
  • sarahwiley