# Fexios

[](https://www.npmjs.com/package/fexios)
[](https://www.npmjs.com/package/fexios)
[](https://github.com/dragon-fish/fexios/actions/workflows/unit-test.yml)
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fdragon-fish%2Ffexios?ref=badge_shield)
Fetch based HTTP client with similar API to axios for browser and Node.js
~~fetch + axios = fexios~~ (Just a joke)
[简体中文](README.zh_CN.md) | [English](README.md)
## Features
- [x] 🤯 Native fetch API (supports the Promise API)
- [x] 🤫 Method shortcuts (`fexios.post()`)
- [x] 🔗 Hooks (intercept request and response)
- [x] 😏 Automatic transform request and response data
- [x] 😏 Automatic transforms for JSON data
- [x] 🤩 Instances with custom defaults
- [x] 🫡 Instance extendable
- [x] 😍 Fricking tiny size: ~6kb (gzipped)
## Installation
**Using package manager**
```sh
# Node Package Manager
npm install fexios
# Why not pnpm
pnpm add fexios
# Or yarn?
yarn add fexios
```
Then import the library and enjoy:
```ts
// Using directly
import fexios from 'fexios'
fexios.get('https://zh.moegirl.org.cn/api.php')
// Yes, it's callable! Just like axios
fexios({
url: 'https://zh.moegirl.org.cn/api.php',
method: 'GET',
})
fexios('https://zh.moegirl.org.cn/api.php', {
method: 'POST',
body: { foo: 'bar' },
})
// Customize instance
import { createFexios, Fexios } from 'fexios'
const fexios = createFexios(/* options */)
const fexios = new Fexios(/* options */)
const fexios = Fexios.create(/* options */)
// Custom instance is also callable
fexios('https://zh.moegirl.org.cn/api.php', {
method: 'POST',
body: { foo: 'bar' },
})
```
**Use directly in the browser**
- ES Module
```ts
import('https://unpkg.com/fexios?module').then(({ createFexios }) => {
const fexios = createFexios(/* options */)
})
```
- UMD bundle
```html
```
## Compatibility
Refer: https://developer.mozilla.org/docs/Web/API/Fetch_API
| Chrome | Edge | Firefox | Opera | Safari | Node.js |
| ------ | ---- | ------- | ----- | --------------- | ---------------------- |
| 42 | 14 | 39 | 29 | 10.1 (iOS 10.3) | ^16.15.0 \|\| >=18.0.0 |
\* Abort signal requires higher version.
## Usage
You can find some sample code snippets [here](test/).
### new Fexios(configs: Partial\