# @types/fetch.io

> TypeScript definitions for fetch.io

Latest version **4.1.5** (published 2023-11-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/fetch.io
pnpm add @types/fetch.io
yarn add @types/fetch.io
bun add @types/fetch.io
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 4.1.5 |
| Published | 2023-11-22 |
| First published | 2017-03-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51438 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/fetch.io
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/fetch.io
- npm.io page: https://npm.io/package/@types/fetch.io

## Recent versions

- 4.1.5 (latest) — 2023-11-22
- 4.1.1 (ts3.6) — 2021-07-08
- 4.1.0 (ts2.2) — 2017-07-14
- 3.1.0 (ts2.0) — 2017-03-08
- 4.1.4 — 2023-11-07
- 4.1.3 — 2023-10-18
- 4.1.2 — 2023-09-14
- 4.0.0 — 2017-06-20
- 3.1.4 — 2017-05-19
- 3.1.3 — 2017-04-17
- 3.1.2 — 2017-03-30
- 3.1.1 — 2017-03-22

## README

# 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](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/fetch.io/index.d.ts)
````ts
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;

    // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
    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: Wed, 22 Nov 2023 00:24:48 GMT
 * Dependencies: none

# Credits
These definitions were written by [newraina](https://github.com/newraina).

---
_Source: https://npm.io/package/@types/fetch.io · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
