A fetch
-like function. Should take two parameters and return a Promise<BasicResponse>
.
BasicResponse
requires only status
, arrayBuffer
, blob
, formData
, json
and text
properties of standard Response
type to be defined.
Non-throwing fetch
wrapper
An object to map response.status
to validating transform. Keys can be response
status numbers + ok
and notOk
. If no mapping for received response status specified, it
will use ok
transform for statuses in the inclusive range from 200 to 299 and notOk
otherwise. Both ok
and notOk
just return SuccessResult
with received Response
object by
default. Each transform is an object that represents a mapping from body reading method
(json
, text
, blob
, arrayBuffer
, formData
) to
(body: BodyType, response: Response) => Result
validating transform or an object without
body mapping - { noBody: (response: Response) => Result }
. If validation fails it should
return FailureResult
and SuccessResult
otherwise.
fetch
function first argument
fetch
function second argument
Success or failure result.
fetch
function itself did throw an error then a failure result containing an
object with clientError
property set to thrown value will be returned.mapError
property set to thrown value will be returned.validationError
property set to
validation error will be returned.serverError
property set to transformed value will be returned.Generated using TypeDoc
Creates a
fetchmap
from third-partyfetch
function.