second-fetcher
v1.7.0
Published
Second is a component rendering service
Downloads
8
Readme
Second Fetcher
Installation
npm install --save second-fetcher
API
new Fetcher({ ?handlers, ?request, ?disableFetchHandler }) -> Fetcher
Constructs a new fetcher.
Arguments
handlers
(Array): An array of handler functions. When given a request whereuri
is not astring
, fetcher will iterate over the handlers, calling them in turn until one returns astring
.request
(Function): A function that takes a single parameter,url
, and returns aPromise
that resolves to an object withbody
andstatusCode
properties.disableFetchHandler
(Boolean): By default the fetcher will inspect fetch results to check HTTP status code and handle any errors. This can be disabled, for example to implement custom result handling.
request(requests) -> Object
Makes a request for each RequestObject
in requests
. Returns an object of type { [string]: Promise }
, where the keys When there are no more outstanding requests, the return value
Arguments
requests
({ [string]: RequestObject }): An object where each key is a request identifier, and the values areRequestObject
s.