# @koibanx/http

> Koibanx's Axios based generic HTTP module

Latest version **0.2.1** (published 2025-06-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install @koibanx/http
pnpm add @koibanx/http
yarn add @koibanx/http
bun add @koibanx/http
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

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

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

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2025-06-02 |
| First published | 2022-06-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 51 KB |
| Known vulnerabilities | 0 (+24 in 1 direct dependencies) |
| Install scripts | no |
| Author | Koibanx |
| Maintainers | npm_koibanx, infra-koibanx |

## Links

- npm: https://www.npmjs.com/package/@koibanx/http
- npm.io page: https://npm.io/package/@koibanx/http

## Dependencies (3)

- [axios](https://npm.io/package/axios.md) ^0.30.0
- [js-cookie](https://npm.io/package/js-cookie.md) ^3.0.1
- [agentkeepalive](https://npm.io/package/agentkeepalive.md) ^4.5.0

## Recent versions

- 0.2.1 (latest) — 2025-06-02
- 1.0.0-rc.1 (rc) — 2025-11-04
- 1.0.0 — 2024-05-03
- 0.2.0 — 2023-11-30
- 0.1.0 — 2023-10-24
- 0.0.6 — 2023-08-03
- 0.0.5 — 2023-08-03
- 0.0.4 — 2022-08-21
- 0.0.3 — 2022-08-10
- 0.0.2 — 2022-07-05
- 0.0.1 — 2022-06-29

## README

## HTTP

Koibanx's Axios based generic HTTP module

### Installation

Add the dependency to your package.json file by running

`npm install @koibanx/http`

> NOTE: you **must** have the npm token in your .npmrc file

### Usage

Initialize the client by setting the optional default parameters:

* baseURL: string
* timeout: number
* baseHeaders: object
* requestInterceptors: Array<(request: any) => Promise<void>>
* responseInterceptors: Array<(response: any) => Promise<void>>

### Full example

```typescript
import http from "@koibanx/http";

const baseURL = "anyurl.com/api"
const timeout = 5000
const baseHeaders = {
    "Authorization": "JWT some-token",
    "Content-Type": "application/json"
}

const logRequestInterceptor = (request) => console.log("Request:", request)
const logResponseInterceptor = (response) => console.log("Response:", response)

const requestInterceptors = [logRequestInterceptor]
const responseInterceptors = [logResponseInterceptor]

// initialize client
const client = http({ baseURL, timeout, baseHeaders, requestInterceptors, responseInterceptors })

const extraHeaders = { "Custom-Header": "SOME_VALUE" }
const foos = await httpGet({url: "/foo", headers: extraHeaders})
console.log("Received foos", foos)

const bar = {
    bar: "bar"
}

const createdBar = await httpPost({url: "/bar", headers: extraHeaders, body: bar})
console.log("Received response", createdBar)



```

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