You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// ReaderTaskEither for better composabilityinterfaceReq<A>extendsRTE.ReaderTaskEither<ReqInput,Err,Resp<A>>{}// Maps fetch()'s parameterstypeReqInput=RequestInfo|RequestInfoInit;typeRequestInfoInit=[RequestInfo,RequestInit];// A response carries the actual data (already retrieved) and the original ResponseinterfaceResp<A>{response: Response;data: A;}// Just two kind of errorstypeErr=RequestError|ResponseError;// Request error carries the original input of ReqinterfaceRequestError{type: 'RequestError';error: Error;input: RequestInfoInit;}// Response error carries the original ResponseinterfaceResponseError{type: 'ResponseError';response: Response;error: Error;}
Combinators
In order to make extending the library functionalities easier, any other feature should then be expressed as simple combinator Req<A> -> Req<A>.
So, for example, decoding the response body as JSON:
// `HeadersInit` is the type of the `headers` key in the fetch()'s `init` parameter// see https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#ParametersdeclarefunctionwithHeaders<A>(hs: HeadersInit): (req: Req<A>)=>Req<A>;
or setting request's body (for POSTs or PUTs):
// `body` can be a plain object/JSONdeclarefunctionwithBody<A>(body: unknown): (req: Req<A>)=>Req<A>;
The text was updated successfully, but these errors were encountered:
It's time to make
appy
more Contactlab-agnostic...This will impact the API and how to extend the base functionalities in order to respond to different needs.
Main purposes are:
io-ts
as dependency;request
/api
dichotomy in favour of an unified API;fetch
's objects likeHeaders
,Request
orResponse
in order to make integration easier;Work in progress in the
v3
branchAPI
The base API should be like this
Combinators
In order to make extending the library functionalities easier, any other feature should then be expressed as simple combinator
Req<A> -> Req<A>
.So, for example, decoding the response body as JSON:
or adding headers to the request:
or setting request's body (for
POST
s orPUT
s):The text was updated successfully, but these errors were encountered: