All Projects → googleapis → Gaxios

googleapis / Gaxios

Licence: apache-2.0
An HTTP request client that provides an axios like interface over top of node-fetch. Super lightweight. Supports proxies and all sorts of other stuff.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Gaxios

Request Ip
A Node.js module for retrieving a request's IP address on the server.
Stars: ✭ 501 (+66.45%)
Mutual labels:  request, npm
Phin
Node HTTP client
Stars: ✭ 449 (+49.17%)
Mutual labels:  request, npm
Yvm
🧶 Manage multiple versions of Yarn
Stars: ✭ 265 (-11.96%)
Mutual labels:  npm
Lookforward
A small library that helps you to create smooth transitions between pages with the easiest way
Stars: ✭ 298 (-1%)
Mutual labels:  npm
Express React Fullstack
Simple, Useful Full Stack Express and React Application
Stars: ✭ 286 (-4.98%)
Mutual labels:  npm
Input Range Scss
Styling Cross-Browser Compatible Range Inputs with Sass
Stars: ✭ 272 (-9.63%)
Mutual labels:  npm
Length.js
📏 JavaScript library for length units conversion.
Stars: ✭ 292 (-2.99%)
Mutual labels:  npm
Cors
🔮Supported(Laravel/Lumen/PSR-15/Swoft/Slim/ThinkPHP) - PHP CORS (Cross-origin resource sharing) middleware.
Stars: ✭ 266 (-11.63%)
Mutual labels:  request
Windows Build Tools
📦 Install C++ Build Tools for Windows using npm
Stars: ✭ 3,280 (+989.7%)
Mutual labels:  npm
Draggable Vue Directive
Vue2 directive that handles drag & drop
Stars: ✭ 286 (-4.98%)
Mutual labels:  npm
Netfox
A lightweight, one line setup, iOS / OSX network debugging library! 🦊
Stars: ✭ 3,188 (+959.14%)
Mutual labels:  request
Tooltip Sequence
A simple step by step tooltip helper for any site
Stars: ✭ 287 (-4.65%)
Mutual labels:  npm
Advanced Nodejs
For help, ask in #questions at slack.jscomplete.com
Stars: ✭ 273 (-9.3%)
Mutual labels:  npm
Arcgis Js Api
Minified version of the ArcGIS API for JavaScript
Stars: ✭ 290 (-3.65%)
Mutual labels:  npm
Quickfix
The best stupid idea for fixing problems in node modules.
Stars: ✭ 267 (-11.3%)
Mutual labels:  npm
Gretchen
Making fetch happen in TypeScript.
Stars: ✭ 301 (+0%)
Mutual labels:  request
Npmsearch
blazing fast npm search utility
Stars: ✭ 266 (-11.63%)
Mutual labels:  npm
Pacote
programmatic npm package and metadata downloader (moved!)
Stars: ✭ 281 (-6.64%)
Mutual labels:  npm
Sync Request
Make synchronous web requests with cross platform support.
Stars: ✭ 289 (-3.99%)
Mutual labels:  request
Scroll Hint
A JS library to suggest that the elements are scrollable horizontally, with the pointer icon.
Stars: ✭ 305 (+1.33%)
Mutual labels:  npm

gaxios

npm version codecov Code Style: Google

An HTTP request client that provides an axios like interface over top of node-fetch.

Install

$ npm install gaxios

Example

const {request} = require('gaxios');
const res = await request({
  url: 'https://www.googleapis.com/discovery/v1/apis/'
});

Setting Defaults

Gaxios supports setting default properties both on the default instance, and on additional instances. This is often useful when making many requests to the same domain with the same base settings. For example:

const gaxios = require('gaxios');
gaxios.instance.defaults = {
  baseURL: 'https://example.com'
  headers: {
    Authorization: 'SOME_TOKEN'
  }
}
gaxios.request({url: '/data'}).then(...);

Request 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 base Url to use for the request. Prepended to the `url` property above.
  baseURL: 'https://example.com';

  // The HTTP methods to be sent with the request.
  headers: { 'some': 'header' },

  // The data to send in the body of the request. Data objects will be
  // serialized as JSON.
  //
  // Note: if you would like to provide a Content-Type header other than
  // application/json you you must provide a string or readable stream, rather
  // than an object:
  // data: JSON.stringify({some: 'data'})
  // data: fs.readFile('./some-data.jpeg')
  data: {
    some: 'data'
  },

  // The max size of the http response content in bytes allowed.
  // Defaults to `0`, which is the same as unset.
  maxContentLength: 2000,

  // The max number of HTTP redirects to follow.
  // Defaults to 100.
  maxRedirects: 100,

  // The querystring parameters that will be encoded using `qs` and
  // appended to the url
  params: {
    querystring: 'parameters'
  },

  // By default, we use the `querystring` package in node core to serialize
  // querystring parameters.  You can override that and provide your
  // own implementation.
  paramsSerializer: (params) => {
    return qs.stringify(params);
  },

  // The timeout for the HTTP request. Defaults to 0.
  timeout: 1000,

  // Optional method to override making the actual HTTP request. Useful
  // for writing tests and instrumentation
  adapter?: async (options, defaultAdapter) => {
    const res = await defaultAdapter(options);
    res.data = {
      ...res.data,
      extraProperty: 'your extra property',
    };
    return res;
  };

  // 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,

  // Implementation of `fetch` to use when making the API call. By default,
  // will use the browser context if available, and fall back to `node-fetch`
  // in node.js otherwise.
  fetchImplementation?: typeof fetch;

  // 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 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) => Promise<void> | void;

    // Function to invoke which determines if you should retry
    shouldRetry?: (err: GaxiosError) => Promise<boolean> | boolean;

    // When there is no response, the number of retries to attempt. Defaults to 2.
    noResponseRetries?: number;

    // The amount of time to initially delay the retry, in ms.  Defaults to 100ms.
    retryDelay?: number;
  },

  // Enables default configuration for retries.
  retry: boolean,

  // Cancelling a request requires the `abort-controller` library.
  // See https://github.com/bitinn/node-fetch#request-cancellation-with-abortsignal
  signal?: AbortSignal
}

License

Apache-2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].