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

fetch-axios_like-js

v0.0.0

Published

☁ fetch 类网络请求的封装库

Downloads

4

Readme

utils-axiosLike-js

简介

☁ fetch 类网络请求的封装库。某些项目、框架不允许直接使用 axios 之类的 HTTP 请求库,所以需要对项目/框架自带的 fetch 请求进行简单封装。

  • 【华为小圆】华为不允许直接使用 axios 之类的 http 请求,否则在「厂商测试云」环境会出现 https 请求失败。华为提供的 fetch 请求方法只是简单的回调,没有 Promise 封装、共用配置、超时、拦截器等功能,所以需要当前项目作为 npm 插件。
  • 【快应用项目】没有 xhr 对象,也没有 axios 库,只有简单的 fetch 函数。类似功能的快应用网络请求库「Flyjs」又不是很符合 axios 的代码习惯。

开发说明

本项目基于「单元测试驱动」进行开发,就是先写设定功能,再写该功能的单元测试,最后写工程代码,让单元测试通过。纯 js 的工具都建议用这种方式进行开发。

  • 启动项目

    • 安装全局 jasmine:cnpm i jasmine -g
    • 安装相关 npm 包:cnpm i
    • 在 Webstorm 中配置 jasmine 环境并运行(右键-run),如图所示test-config
    • 点击运行,可以启动所有 jasmine 的单元测试(/spec 文件夹下)
    • 查看结果
    • 结果无误后,可以修改 /src 的代码进行功能增加,或者增加 /spec 下的单元测试进行更细致的测试
  • 代码设计解读:【util-axiosLike】代码解读

    • 设计基于 Axios,只是把 HTTP 请求部分的功能剔除,传入 request 属性代替这部分
    • 如果对项目进行了更新,请更新文章,维持良好的设计素质