4.1.5 • Published 6 months ago

@types/fetch.io v4.1.5

Weekly downloads
64
License
MIT
Repository
github
Last release
6 months ago

Installation

npm install --save @types/fetch.io

Summary

This package contains type definitions for fetch.io (https://github.com/haoxins/fetch.io).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/fetch.io.

index.d.ts

// Type definitions for fetch.io 4.1
// Project: https://github.com/haoxins/fetch.io
// Definitions by: newraina <https://github.com/newraina>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2

export type TUrl = string;

export type TMethod = 'delete' | 'get' | 'head' | 'options' | 'post' | 'put';

export interface Query {
  [key: string]: number | boolean | string;
}

export interface Header {
  [key: string]: string;
}

export interface Options extends RequestInit {
  prefix?: string | undefined;

  query?: Query | undefined;

  header?: Header | undefined;

  beforeRequest?(url: TUrl, body: BodyInit): boolean | void;

  afterResponse?(res: Response): void;

  afterJSON?(body: any): void;
}

export class Request {
  constructor(method: TMethod, url: TUrl, options: Options)

  /**
   * HTTP delete method
   */
  delete: (url: TUrl) => this;

  /**
   * HTTP get method
   */
  get: (url: TUrl) => this;

  /**
   * HTTP head method
   */
  head: (url: TUrl) => this;

  /**
   * HTTP options method
   */
  options: (url: TUrl) => this;

  /**
   * HTTP post method
   */
  post: (url: TUrl) => this;

  /**
   * HTTP put method
   */
  put: (url: TUrl) => this;

  /**
   * HTTP patch method
   */
  patch: (url: TUrl) => this;

  /**
   * Set Options
   */
  config(key: string, value: any): this;

  config(opts: {[key: string]: any}): this;

  /**
   * Set Header
   */
  set(key: string, value: any): this;

  set(opts: {[key: string]: any}): this;

  /**
   * Set Content-Type
   */
  type(type: 'json' | 'form' | 'urlencoded'): this;

  /**
   * Add query string
   */
  query(object: {[key: string]: any}): this;

  /**
   * Send data
   */
  send(data: {[key: string]: any}): this;

  /**
   * append formData
   */
  append(key: string, value: any): this;

  append(object: {[key: string]: any}): this;

  /**
   * Get Response directly
   */
  then(resolve: (value?: Response) => void, reject?: (reason?: any) => void): Promise<any>;

  /**
   * Make Response to JSON
   */
  json(strict?: boolean): Promise<any>;

  /**
   * Make Response to string
   */
  text(): Promise<string>;
}

export default class Fetch extends Request {
  constructor(options?: Options)
}

Additional Details

  • Last updated: Thu, 08 Jul 2021 12:01:32 GMT
  • Dependencies: none
  • Global values: none

Credits

These definitions were written by newraina.

4.1.4

7 months ago

4.1.3

7 months ago

4.1.5

6 months ago

4.1.2

8 months ago

4.1.1

3 years ago

4.1.0

7 years ago

4.0.0

7 years ago

3.1.4

7 years ago

3.1.3

7 years ago

3.1.2

7 years ago

3.1.1

7 years ago

3.1.0

7 years ago