# api-request-client

> axios request wrapper

Latest version **0.0.10** (published 2019-04-24) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.10 |
| Published | 2019-04-24 |
| First published | 2018-10-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 21.4 KB |
| Known vulnerabilities | 0 (+24 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | jiseung jung |
| Maintainers | 91debug |

## Links

- npm: https://www.npmjs.com/package/api-request-client
- Repository: https://github.com/91debug/api-request-client
- Homepage: https://github.com/91debug/api-request-client#readme
- Issues: https://github.com/91debug/api-request-client/issues
- npm.io page: https://npm.io/package/api-request-client

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^0.18.0
- [natives](https://npm.io/package/natives.md) ^1.1.6

## Recent versions

- 0.0.10 (latest) — 2019-04-24
- 0.0.9 — 2019-04-24
- 0.0.8 — 2019-04-24
- 0.0.7 — 2019-04-22
- 0.0.6 — 2019-02-08
- 0.0.5 — 2018-10-25
- 0.0.4 — 2018-10-12
- 0.0.3 — 2018-10-08
- 0.0.2 — 2018-10-04
- 0.0.1 — 2018-10-03
- 0.0.0 — 2018-10-03

## README

# api-request-client

[![Build Status](https://travis-ci.org/91debug/api-request-client.svg?branch=master)](https://travis-ci.org/91debug/api-request-client)

axios request wrapper

## Installation

- `yarn add api-request-client` or `npm install api-request-client`

## How to use

### Post

```ts
import { APIRequestClient, ResponseError } from 'api-request-client';

interface User {
  name: string;
}

const createUser = async () => {
  const requestClient = new APIRequestClient({
    url: 'users',
    baseURL: 'http://localhost:8080',
  });
  try {
    const response = await requestClient
      .setMethod('POST')
      .setData({
        name: 'jiseung',
      })
      .send<User>();

    console.log(response.name);
  } catch (err) {
    if (err instanceof ResponseError) {
      if (err.errorResponse.status === 400) {
        alert('bad request');
      }
    }
  }
};
```

### Post form-data

```ts
import { APIRequestClient, ResponseError } from 'api-request-client';

const form: FormData = new FormData();
form.append('test', '1');

const response = await request
  .setMethod('POST')
  .setBodyType('form')
  .setData(form)
  .send<Params>();
```

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