# 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)
类 Axios 语法的原生 fetch API 请求封装库
~~fetch + axios = fexios~~ (神金)
[简体中文](README.zh_CN.md) | [English](README.md)
## 特色功能
- [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: `index.umd.cjs 8.51 kB │ gzip: 3.48 kB │ map: 31.96 kB`
## 安装
**包管理器**
```sh
# Node Package Manager
npm install fexios
# Why not pnpm
pnpm add fexios
# Or yarn?
yarn add fexios
```
然后导入库并开始使用:
```ts
import fexios, { createFexios, Fexios } from 'fexios'
// 直接使用
fexios.get('https://zh.moegirl.org.cn/api.php')
// 带配置项使用
const fexios = createFexios(/* options */)
const fexios = new Fexios(/* options */)
const fexios = Fexios.create(/* options */)
```
**在浏览器中直接使用**
- JS Module
```ts
import('https://unpkg.com/fexios?module').then(({ createFexios }) => {
const fexios = createFexios(/* options */)
})
```
- 全局变量
```html
```
## 兼容性
参考: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 需要更高版本。
## 使用方法
你可以在[这里](test/)找到一些示例代码片段。
### new Fexios(configs: Partial\