Neatly Prepared Mustache

    @types/fetch.io
    TypeScript icon, indicating that this package has built-in type declarations

    4.1.1 • Public • Published

    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.

    Keywords

    none

    Install

    npm i @types/fetch.io

    DownloadsWeekly Downloads

    27

    Version

    4.1.1

    License

    MIT

    Unpacked Size

    7.01 kB

    Total Files

    4

    Last publish

    Collaborators

    • types