# @vespaiach/axios-fetch-adapter

> Fetch adapter for axios

Latest version **0.3.1** (published 2022-09-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @vespaiach/axios-fetch-adapter
pnpm add @vespaiach/axios-fetch-adapter
yarn add @vespaiach/axios-fetch-adapter
bun add @vespaiach/axios-fetch-adapter
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2022-09-30 |
| First published | 2021-02-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 105 |
| Author | nta.toan@gmail.com |
| Maintainers | vespaiach |
| Keywords | axios, adapter, fetch |

## Links

- npm: https://www.npmjs.com/package/@vespaiach/axios-fetch-adapter
- Repository: https://github.com/vespaiach/axios-fetch-adapter
- Homepage: https://github.com/vespaiach/axios-fetch-adapter#readme
- Issues: https://github.com/vespaiach/axios-fetch-adapter/issues
- npm.io page: https://npm.io/package/@vespaiach/axios-fetch-adapter

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.3.1 (latest) — 2022-09-30
- 0.3.0 — 2022-05-21
- 0.2.2 — 2022-04-01
- 0.2.1 — 2022-04-01
- 0.2.0 — 2022-03-24
- 0.1.1 — 2021-02-15
- 0.1.0 — 2021-02-15

## README

# Why

I'm going to adopt PWA to my web applications and those web apps are heavily using Axios with the default XMLHTTPRequest adapter. Hence, I have to switch to Fetch adapter; However, Axios doesn't have an adapter for fetch API for now. So I write one to use while waiting for an offical one from Axios.

# Installation and Usage

You can install the adapter directly from this repository URL or feel free to copy its source code to your project.

``` sh
npm install axios
npm install @vespaiach/axios-fetch-adapter
```

There are two ways to use it:

1.  Create a new instance of Axios and pass this adapter in configuration

``` js
const instance = axios.create({
  baseURL: 'https://some-domain.com/api/',
  timeout: 1000,
  adapter: fetchAdapter
  ....
});
```

2.  Pass this adapter in each of request

``` js
axios.request({
  url: '/user',
  method: 'get',
  adapter: fetchAdapter
  ...
})
```

3.  Use with FormData 

``` js
axios.request({
  url: '/user',
  method: 'post',
  adapter: fetchAdapter
  data: new FormData(formId)
  ...
})
```

# Note

- Since, this adapter relies on fetch API so it won't work in Node environment

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