All Projects â†’ islizeqiang â†’ electron-request

islizeqiang / electron-request

Licence: MIT License
Zero-dependency, Lightweight HTTP request client for Electron or Node.js

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to electron-request

wumpfetch
🚀🔗 A modern, lightweight, fast and easy to use Node.js HTTP client
Stars: ✭ 20 (-55.56%)
Mutual labels:  fetch, lightweight, https, request
Wretch
A tiny wrapper built around fetch with an intuitive syntax. đŸŦ
Stars: ✭ 2,285 (+4977.78%)
Mutual labels:  fetch, ajax, http-client, request
Gretchen
Making fetch happen in TypeScript.
Stars: ✭ 301 (+568.89%)
Mutual labels:  fetch, http-client, request
Redux Requests
Declarative AJAX requests and automatic network state management for single-page applications
Stars: ✭ 330 (+633.33%)
Mutual labels:  fetch, ajax, http-client
Ky
đŸŒŗ Tiny & elegant JavaScript HTTP client based on the browser Fetch API
Stars: ✭ 7,047 (+15560%)
Mutual labels:  fetch, http-client, request
Request
go request, go http client
Stars: ✭ 105 (+133.33%)
Mutual labels:  client, request, net
Interceptors
Low-level HTTP/HTTPS/XHR/fetch request interception library.
Stars: ✭ 100 (+122.22%)
Mutual labels:  xhr, https, request
vue-methods-promise
Let Vue methods support return Promise
Stars: ✭ 35 (-22.22%)
Mutual labels:  fetch, ajax, request
Ky Universal
Use Ky in both Node.js and browsers
Stars: ✭ 421 (+835.56%)
Mutual labels:  fetch, http-client, request
Create Request
Apply interceptors to `fetch` and create a custom request function.
Stars: ✭ 34 (-24.44%)
Mutual labels:  fetch, http-client, request
Wretch Middlewares
Collection of middlewares for the Wretch library. 🎁
Stars: ✭ 42 (-6.67%)
Mutual labels:  fetch, ajax, request
Http Client
A high-performance, high-stability, cross-platform HTTP client.
Stars: ✭ 86 (+91.11%)
Mutual labels:  https, http-client, request
Phin
Node HTTP client
Stars: ✭ 449 (+897.78%)
Mutual labels:  https, http-client, request
Thwack
A tiny modern data fetching solution
Stars: ✭ 268 (+495.56%)
Mutual labels:  fetch, xhr, ajax
Xhr.js
🌎 xhr.js is a library(< 2Kb) to make AJAX/HTTP requests with XMLHttpRequest.
Stars: ✭ 12 (-73.33%)
Mutual labels:  fetch, xhr, ajax
Frisbee
🐕 Modern fetch-based alternative to axios/superagent/request. Great for React Native.
Stars: ✭ 1,038 (+2206.67%)
Mutual labels:  fetch, xhr, request
http
Tiny, embeddable HTTP client with simple API for the browser
Stars: ✭ 21 (-53.33%)
Mutual labels:  xhr, ajax, http-client
fitch.js
A lightweight Promise based HTTP client, using Fetch API.
Stars: ✭ 35 (-22.22%)
Mutual labels:  fetch, http-client
legible
the cleanest way to make http requests in js / node
Stars: ✭ 49 (+8.89%)
Mutual labels:  fetch, request
sapper-httpclient
An isomorphic http client for Sapper
Stars: ✭ 48 (+6.67%)
Mutual labels:  fetch, xhr

English | įŽ€äŊ“中文

electron-request

Zero-dependency, Lightweight HTTP request client for Electron or Node.js

Why electron-request ?

Electron-request uses its built-in net module in Electron environment and uses its built-in HTTP module in Node.js environment.

Net module is used in electron to better support proxy, authentication, traffic monitoring proxies and other features. Please refer to net for details.

Features

  • Zero-dependency, Lightweight
  • Quick start, similar window.fetch
  • No need to import other libraries, support file download progress and file verification
  • Support to run on Electron or Node.js, use Electron's net module first
  • Unified error handling

Install

npm install electron-request --save
# or
yarn add electron-request

Usage

import request from 'electron-request';

void (async () => {
  const url = 'https://github.com/';
  const defaultOptions = {
    method: 'GET',
    body: null,
    followRedirect: true,
    maxRedirectCount: 20,
    timeout: 0,
    size: 0,
  };
  const response = await request(url, defaultOptions);
  const text = await response.text();
})();

API

request(url[, options])

  • url: Request URL

  • options: Options

    interface Options {
      /**
       * Request method
       * @default 'GET'
       */
      method?: string;
      /**
       * Request body
       * @default null
       */
      body?: string | null | Buffer | Stream;
      /**
       * Request headers
       */
      headers?: Record<string, string | string[]>;
      /**
       * Request query
       */
      query?: Record<string, string>;
      /**
       * Allow redirect
       * @default true
       */
      followRedirect?: boolean;
      /**
       * Maximum redirect count. 0 to not follow redirect
       * @default 20
       */
      maxRedirectCount?: number;
      /**
       * Request/Response timeout in ms. 0 to disable
       * @default 0
       */
      timeout?: number;
      /**
       * Maximum response body size in bytes. 0 to disable
       * @default 0
       */
      size?: number;
      /**
       * Whether to use nodejs native request
       * @default false
       */
      useNative?: boolean;
    
      // Docs: https://www.electronjs.org/docs/api/client-request#new-clientrequestoptions
    
      /**
       * Only in Electron. When use authenticated HTTP proxy, username to use to authenticate
       */
      username?: string;
      /**
       * Only in Electron. When use authenticated HTTP proxy, password to use to authenticate
       */
      password?: string;
      /**
       * Only in Electron. Whether to send cookies with this request from the provided session
       * @default true
       */
      useSessionCookies?: boolean;
      /**
       * Only in Electron. The Session instance with which the request is associated
       * @default electron.session.defaultSession
       */
      session?: Session;
    }

Response

interface Response {
  /** Whether the response was successful (status in the range 200-299) */
  ok: boolean;
  /** Response headers */
  headers: Record<string, string | string[]>;
  /** Return origin stream */
  stream: Stream;
  /** Decode response as ArrayBuffer */
  arrayBuffer(): Promise<ArrayBuffer>;
  /** Decode response as Blob */
  blob(): Promise<Blob>;
  /** Decode response as text */
  text(): Promise<string>;
  /** Decode response as json */
  json<T>(): Promise<T>;
  /** Decode response as buffer */
  buffer(): Promise<Buffer>;
  /**
   * Download file to destination
   * @param {Writable} destination Writable destination stream
   * @param {ProgressCallback=} onProgress Download progress callback
   * @param {ValidateOptions=} validateOptions Validate options
   */
  download: (
    destination: Writable,
    onProgress?: ProgressCallback,
    validateOptions?: ValidateOptions,
  ) => Promise<void>;
}

/** Download progress information */
interface ProgressInfo {
  /** Total file bytes */
  total: number;
  /** Delta file bytes */
  delta: number;
  /** Transferred file bytes */
  transferred: number;
  /** Transferred percentage */
  percent: number;
  /** Bytes transferred per second */
  bytesPerSecond: number;
}

License

MIT License

electron-request vs. the Competition

Package Size
request request package size
axios axios package size
node-fetch node-fetch package size
request-pure request-pure package size
electron-request electron-request package size
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].