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 🙏

© 2024 – Pkg Stats / Ryan Hefner

sasai-axios

v1.0.0

Published

My webpack project

Downloads

4

Readme

Axios 封装

导语

普通的项目直接使用 Axios 已经是足够的,但是相对复杂的项目,尤其是使用不同的后端服务,axios需要针对于不同的服务做出不同的配置或者处理, 就需要创建多个axios,简单粗暴的同学会多复制一份axios.js,这样能处理问题,但是不符合编程思想,所以使用类语法进行封装,来创建多个实例,一套代码传入不同配置来应对不同的需求

JS版本1.0

  • 可创建多个axios实例, 实现多个实例不同, 支持传入配置 baseURL默认接口地址, timeout超时时间
  • 增加请求优化配置 clear是否取消重复请求,同一时间内同个接口 如果在 pending 中则取消之前的请求
  • 抛出了 clearPending 方法 清空 pending 中的请求(在路由跳转时调用)优化请求带宽

TS版本1.0 (主要参考网上代码,以及代码解析

  • 可创建多个axios实例, 实现多个实例不同, 支持传入配置 axios 所有支持的配置,并支持手动传入自定义拦截器
  • 拦截器更加灵活,有全局、实例、接口三种拦截器。
  • 增加请求优化配置 可以移除请求
  • TS语法,代码更加规范化,减少运行错误发生