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 🙏

© 2026 – Pkg Stats / Ryan Hefner

zzh-axios

v1.1.0

Published

1. 请求数据拦截器 2. 响应数据拦截器 3. 支持 promiseAPI 4. 支持请求数据和响应数据转换 5. JSON 数据自动转换 6. 客户端防止 XSRF

Readme

一个简单的 Axios(自用)

支持功能

  1. 请求数据拦截器
  2. 响应数据拦截器
  3. 支持 promiseAPI
  4. 支持请求数据和响应数据转换
  5. JSON 数据自动转换
  6. 客户端防止 XSRF

参数说明

  1. axios(config)

    axios 方法接收一个 config 对象

  2. config.url: string

    config.url <必须> 指定请求接口,参数类型为一个 string

  3. config.method?: Method

    config.method[可选]指定请求方法,默认为 get 方法,如果 data 中有数据则默认为 post 方法,参数类型为常用的请求方法

  4. config.data?: any

    config.data[可选]请求接口需要发送的数据,参数类型为对象

  5. config.params?: any

    config.params[可选],url 地址参数,参数类型为任意类型

  6. config.timeout?: number

    config.timeout[可选],指定请求超时时间(毫秒数),参数类型为 number

  7. config.headers?: number

    config.headers[可选],请求头部,参数类型为对象

  8. config.responseType?: XMLHttpRequestResponseType

    config.responseType[可选],指定响应数据类型,参数类型 XMLHttpRequestResponseType

  9. config.transformRequest?: (config:config)=>config

    config.transformRequest[可选],发起请求前会调用该回调函数,参数类型函数

  10. config.transformResponse?: (data:data)=>data

    config.transformResponse[可选],请求响应后会调用该回调函数,参数类型函数

  11. config.withCredentials?:boolean

    config.withCredentials[可选],发起请求时是否携带 cookie,参数类型 boolean

  12. config.onDownloadProgress?: (e.ProgressEvent)=>void

    config.onDownloadProgress[可选],下载文件数据时会调用该函数,参数类型函数

  13. config.onUploadProgress?: (e.ProgressEvent)=>void

    config.onUploadProgress[可选],上传文件数据时会调用该函数,参数类型函数

  14. config.validateStatus?: (status:number)=>boolean

    config.validateStatus[可选],自定义响应数据安全范围,默认 200~300,参数类型函数

  15. config.paramsSerializer?:(params:any) => string

    config.paramsSerializer[可选],自定义解析 params 参数,参数类型函数

  16. config.baseURL?: string

    config.paramsSerializer[可选],请求发起的公共头部,如果 url 是一个绝对路径则不作处理,参数类型函数

  17. config.xsrfCookieName?:string

    config.xsrfCookieName[可选],请求发起时在 cookie 中寻找的 token 参数,参数类型 string

  18. config.xsrfHeaderName?:string

    config.xsrfHeaderName[可选],请求发起时 token 的头部,参数类型 string

  19. axios.defaults.get

    默认的请求方法

  20. axios.defaults.timeout

    默认的超时时间

  21. axios.defaults.headers.common

    默认的请求公共头部

  22. axios.defaults.xsrfCookieName

    默认的 cookie token

  23. axios.defaults.xsrfHeaderName

    默认的 token 请求头部

方法说明

  1. axios.post(url:string,data?:any,config?:config):promise

    post 请求 url<必须> data[可选]

  2. axios.put(url:string,data?:any,config?:config):promise

    put 请求 url<必须> data[可选]config 可选

  3. axios.patch(url:string,data?:any,config?:config):promise

    patch 请求 url<必须> data[可选]config 可选

  4. axios.get(url:string,params?:any,config:?config):promise

    get 请求 url<必须> params[可选]config 可选

  5. axios.delete(url:string,params?:any,config?:config):promise

    delete 请求 url<必须> params[可选]config 可选

  6. axios.head(url:string,params?:any,config?:config):promise

    head 请求 url<必须> params[可选]config 可选

  7. axios.options(url:string,params?:any,config?:config):promise

    options 请求 url<必须> params[可选]config 可选

  8. axios.request(url:string,config:config):promise

    request 方法 url<必须> config<必须>

  9. axios.interceptors.request.use((config)=>void):number

    请求拦截器,参数函数,接收参数 config,返回一个 id

  10. axios.interceptors.response.use((data)=>void):number

    响应拦截器,参数函数,接收参数 config,返回一个 id

  11. axios.interceptors.response.eject(id:number):void

    根据 id 删除指定的响应拦截器

  12. axios.interceptors.request.eject(id:number):void

    根据 id 删除指定的请求拦截器