index/functions/httpRequestorFromAxios.md
httpRequestorFromAxios(
instance,options):HttpRequestor
An SDK HttpRequestor over an axios instance, so the SDK's requests travel through the app's own base URL, interceptors and error handling.
A POST's string body is parsed back to the object the SDK serialized it from (axios serializes
again, and an interceptor may read the object); a GET goes through instance.get. The answer
is an HTTP response whose json()/text() read response.data. An answer that is not an
axios response is a TRANSPORT_ERROR rejection, and so is a rejection that means no HTTP
answer arrived (the original error is cause): any rejection with rejectOnHttpError: false
(every status resolves there), an axios error without a response with true. Any other
rejection (an interceptor's error for a 4xx, say) is rethrown unchanged, and so is an abort.
Pair it with ChainGateway's dexBackendBaseUrl: '' when the instance owns the base URL.
http requestor transport error reject on chain gateway dex backend base url
Parameters
| Parameter | Type |
|---|---|
instance | AxiosLikeInstance |
options | AxiosRequestorOptions |
axios like instance requestor options
Returns
http requestor
Example
const submitGateway = new ChainGateway({
dexBackendBaseUrl: '',
httpRequestor: httpRequestorFromAxios(chainGatewayInstance, { rejectOnHttpError: true }),
});