npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

axios-adapter-fetch

v1.0.7

Published

axios对应fetch请求的适配器, 使用axios的方式操作fetch请求

Downloads

6

Readme

为什么会写这个

平时工作中一般是用axios, 对其方法属性都比较熟悉了, 而且项目中的相关配置也比较庞大. 现在想使用fetch方法代替XMLHttpRequest, 就想在axios的基础上增加对fetch的支持, 所以写了这个对于fetch的适配器, 无需改动原来的axios接口逻辑, 任何属性方法都是一致且支持的(除了上传进度,这个fetch不支持)

优势

  1. 体积小, 压缩后不足1kb
  2. 使用fetch代替XMLHttpRequest
  3. 完全兼容axios原来方法, 文档见axios官网即可, 无fetch学习负担

安装和使用

安装axios和这个适配器

npm install axios
npm install axios-adapter-fetch

两种方式都可使用(关键在于adapter, 这个即是axios对应fetch的适配器):

  1. 创建Axios的新实例,并在配置中传递此适配器
import adapter from 'axios-adapter-fetch';

const instance = axios.create({
  baseURL: 'https://some-domain.com/api/',
  timeout: 1000,
  adapter
  ....
});
  1. 在每个请求中传递此适配器
import adapter from 'axios-adapter-fetch';

axios.request({
  url: '/user',
  method: 'get',
  adapter
  ...
})

注:

  • 这个适配器依赖于fetch API, 所以在nodejs中使用前提需要nodejs支持fetch API