http-client
Advanced tools
Comparing version 4.3.0 to 4.3.1
{ | ||
"name": "http-client", | ||
"version": "4.3.0", | ||
"version": "4.3.1", | ||
"description": "Compose HTTP clients using JavaScript's fetch API", | ||
@@ -5,0 +5,0 @@ "repository": "mjackson/http-client", |
@@ -27,6 +27,5 @@ # http-client [![Travis][build-badge]][build] [![npm package][npm-badge]][npm] | ||
// using ES6 modules | ||
import { fetch, createFetch } from 'http-client' | ||
import { createFetch } from 'http-client' | ||
// using CommonJS modules | ||
var fetch = require('http-client').fetch | ||
var createFetch = require('http-client').createFetch | ||
@@ -73,3 +72,3 @@ ``` | ||
Returns an "enhanced" version of the given `fetch` function that uses an array of transforms in `options.responseHandlers` to modify the response after it is received. This is only really useful when using [stacks](#stacks) directly instead of the global `fetch` function. | ||
Returns an "enhanced" version of the given `fetch` function that knows how to run response handlers registered using [`recv`](#recvhandler). This is only really useful when using [stacks](#stacks) directly instead of `createFetch`. | ||
@@ -130,2 +129,19 @@ ## Middleware | ||
#### `debug()` | ||
Adds a `debug` property to the response or error object so you can inspect them. Mainly useful for testing/debugging (should run *after* all other middleware). | ||
```js | ||
import { createFetch, debug } from 'http-client' | ||
const fetch = createFetch( | ||
// ... other middleware | ||
debug() | ||
) | ||
fetch(input).then(response => { | ||
console.log(response.debug.input, response.debug.options) | ||
}) | ||
``` | ||
#### `header(name, value)` | ||
@@ -231,19 +247,2 @@ | ||
#### `requestInfo()` | ||
Adds `requestURL` and `requestOptions` properties to the response (or error) object so you can inspect them. Mainly useful for testing/debugging (should be put last in the list of middleware). | ||
```js | ||
import { createFetch, requestInfo } from 'http-client' | ||
const fetch = createFetch( | ||
// ... | ||
requestInfo() | ||
) | ||
fetch(input).then(response => { | ||
console.log(response.requestURL, response.requestOptions) | ||
}) | ||
``` | ||
## Stacks | ||
@@ -250,0 +249,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45349
293