Package Exports
- gaxios
- gaxios/build/src/common
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gaxios) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
gaxios
An HTTP request client that provides an
axios
like interfance over top ofnode-fetch
. Only really useful if you're trying to migrate from axios to the fetch.
Install
$ npm install gaxios
Example
const {request} = require('gaxios');
const res = await request({
url: 'https://www.googleapis.com/discovery/v1/apis/'
});
Options
{
// The url to which the request should be sent. Required.
url: string,
// The HTTP method to use for the request. Defaults to `GET`.
method: 'GET',
// The HTTP methods to be sent with the request.
headers: { 'some': 'header' },
// The data to base64 encode and send in the body of the request.
data: {
some: 'data'
},
// The querystring parameters that will be encoded using `qs` and
// appended to the url
params: {
querystring: 'parameters'
},
// The timeout for the HTTP request. Defaults to 0.
timeout: 1000,
// The expected return type of the request. Options are:
// json | stream | blob | arraybuffer | text
// Defaults to `json`.
responseType: 'json',
// The node.js http agent to use for the request.
agent: someHttpsAgent,
// Custom function to determine if the response is valid based on the
// status code. Defaults to (>= 200 && < 300)
validateStatus: (status: number) => true,
// Configuration for retrying of requests.
retryConfig: {
// The number of times to retry the request. Defaults to 3.
retry?: number;
// The number of retries already attempted.
currentRetryAttempt?: number;
// The amount of time to initially delay the retry. Defaults to 100.
retryDelay?: number;
// The HTTP Methods that will be automatically retried.
// Defaults to ['GET','PUT','HEAD','OPTIONS','DELETE']
httpMethodsToRetry?: string[];
// The HTTP response status codes that will automatically be retried.
// Defaults to: [[100, 199], [429, 429], [500, 599]]
statusCodesToRetry?: number[][];
// Function to invoke when a retry attempt is made.
onRetryAttempt?: (err: GaxiosError) => void;
// Function to invoke which determines if you should retry
shouldRetry?: (err: GaxiosError) => boolean;
// When there is no response, the number of retries to attempt. Defaults to 2.
noResponseRetries?: number;
},
// Enables default configuration for retries.
retry: boolean;
}