# request-it-client

> Yet another client library for working with http/s requests.

Latest version **1.4.1** (published 2020-10-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install request-it-client
pnpm add request-it-client
yarn add request-it-client
bun add request-it-client
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.1 |
| Published | 2020-10-26 |
| First published | 2020-07-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 22 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Aaron Huggins |
| Maintainers | ahuggins_nhs |
| Keywords | http, simple, util, utility |

## Links

- npm: https://www.npmjs.com/package/request-it-client
- Repository: https://github.com/ahuggins-nhs/request-it
- Homepage: https://github.com/ahuggins-nhs/request-it#readme
- Issues: https://github.com/ahuggins-nhs/request-it/issues
- npm.io page: https://npm.io/package/request-it-client

## Dependencies (1)

- [tough-cookie](https://npm.io/package/tough-cookie.md) ^4.0.0

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.4.1 (latest) — 2020-10-26
- 2.0.0-beta2 (beta) — 2022-01-14
- 2.0.0-beta — 2022-01-14
- 1.4.0 — 2020-10-11
- 1.3.3 — 2020-08-03
- 1.3.2 — 2020-08-03
- 1.3.1 — 2020-08-03
- 1.3.0 — 2020-08-03
- 1.2.3 — 2020-08-02
- 1.2.2 — 2020-08-02
- 1.2.1 — 2020-08-02
- 1.2.0 — 2020-08-02
- 1.1.0 — 2020-08-01
- 1.0.0 — 2020-07-31

## README

# RequestIt Client

A stupidly simple HTTP client for Node-JS that should just work. Built-in support for cookies, JSON, and may follow up to a max of 20 redirects.

## Usage

Install via [NPM](https://www.npmjs.com/package/request-it-client) and require in your project. Then request it and go!

```js
const { RequestIt } = require('request-it-client')

;(async function main () {
  const res = await RequestIt.go('https://reqres.in/api/users/2')

  console.log(res.body.data.first_name) // expected result: Janet
})()
```

## API

### `class RequestIt`

- `new RequestIt(options?: RequestOptions)`
- **Instance Members**
  - `public options: RequestOptions`
  - `public cookieJar: RequestItCookieJar`
  - `public go(options?: RequestOptions | string | URL): Promise<IncomingMessage>`
  - `public get(options?: RequestOptions | string | URL): Promise<IncomingMessage>`
  - `public patch(options?: RequestOptions | string | URL): Promise<IncomingMessage>`
  - `public post(options?: RequestOptions | string | URL): Promise<IncomingMessage>`
  - `public put(options?: RequestOptions | string | URL): Promise<IncomingMessage>`
  - `public delete(options?: RequestOptions | string | URL): Promise<IncomingMessage>`
- **Static Members**
  - `static go(options?: RequestOptions | string | URL): Promise<IncomingMessage>`
  - `static get(options?: RequestOptions | string | URL): Promise<IncomingMessage>`
  - `static patch(options?: RequestOptions | string | URL): Promise<IncomingMessage>`
  - `static post(options?: RequestOptions | string | URL): Promise<IncomingMessage>`
  - `static put(options?: RequestOptions | string | URL): Promise<IncomingMessage>`
  - `static delete(options?: RequestOptions | string | URL): Promise<IncomingMessage>`

### `interface RequestOptions`

See NodeJS docs for [details](https://nodejs.org/docs/latest-v12.x/api/http.html#http_http_request_options_callback).

- **Extended Properties**
  - `url: string | URL`
  - `cookieJar?: RequestItCookieJar | CookieJar`; Support for Tough Cookie cookie jars.
  - `body?: string | Buffer | object | any[]`; Raw data to send, an object or array will be JSONified.
  - `json?: object | any[]`; Support for JSON data.
  - `form?: { [key: string]: string | boolean | number }` Support for forms data.
  - `responseType?: 'json'`; Any response will attempt to be parsed regardless of content-type.
  - `rejectBadJson?: boolean`; Setting to `true` will throw an error on unparsable JSON.
  - `followRedirect?: boolean`; Set to `true` by default, controls whther or not to follow redirects.
  - `maxRedirects?: number`; Maximum number of redirects to follow with a hard limit of 20, defaults to 3.
  - `params?: { [key: string]: string | boolean | number }`; URL parameters to pass.

### `interface IncomingMessage`

See NodeJS docs for [details](https://nodejs.org/docs/latest-v12.x/api/http.html#http_class_http_incomingmessage).

- **Extended Properties**
  - `json: () => any`
  - `body: any`
  - `cookieJar: RequestItCookieJar`
  - `rawResponse: Buffer`
  - `rawBody: Buffer`

### `class RequestItCookieJar extends CookieJar`

Extends `tough-cookie` [cookie jar class](https://github.com/salesforce/tough-cookie#cookiejar).

- `new RequestItCookieJar(store?: Store, options?: CookieJar.Options)`
- **Instance Members**
  - `public findCookie(domain: string, path: string, key: string): Promise<Cookie>`
- **Static Members**
  - `static fromCookieJar(cookieJar: CookieJar): RequestItCookieJar`

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