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

rk-axios

v0.0.8

Published

axios的封装: 1. 暴露出两个方法:错误时回调函数:setErrorCallback,请求前的钩子函数setBeforeRequire。 2. 对get函数进行封装,第二个参数是数据,第三个参数是AxiosRequestConfig 3. 对所有请求的data数据进行封装,传递json格式即可,库会进行转换 # Install ```` yarn add rk-axios ```` # Usage ```` import rkAxios from 'rk-axios' rkAxios.get('ht

Downloads

6

Readme

axios的封装:

  1. 暴露出两个方法:错误时回调函数:setErrorCallback,请求前的钩子函数setBeforeRequire。
  2. 对get函数进行封装,第二个参数是数据,第三个参数是AxiosRequestConfig
  3. 对所有请求的data数据进行封装,传递json格式即可,库会进行转换

Install

yarn add rk-axios

Usage

import rkAxios from 'rk-axios'
rkAxios.get('https://www.linchaoqun.com/html/cms/content.jsp',{
  menu : 'index',
  id: '02b84ae2-b29e-46e6-8b06-2db5c99d3772'
}).then(()=>{
})

API

import { AxiosRequestConfig } from 'axios';
interface ErrorCallback {
    (e: Error): void;
}
export interface BeforeRequireReturn {
    data?: string | JSON;
    option?: AxiosRequestConfig;
}
interface BeforeRequire {
    (option?: AxiosRequestConfig, data?: string | JSON): BeforeRequireReturn;
}
export declare const rkAxios: {
    /**
     * 错误请求时回调
     * @param callback ErrorCallback: (e: Error): void;
     */
    setErrorCallback(callback: ErrorCallback): void;
    /**
     * 设置请求前钩子
     * @param callback BeforeRequire (option?: AxiosRequestConfig, data?: string | JSON): BeforeRequireReturn;
     * BeforeRequireReturn: {
        data?: string | JSON;
        option?: AxiosRequestConfig;
      }
     */
    setBeforeRequire(callback: BeforeRequire): void;
    /**
     * post请求
     * @param url 路径
     * @param data 数据
     * @param option http选项
     * @returns {Promise<*>}
     */
    post: (url: any, data?: any, option?: any) => Promise<void>;
    /**
     * patch请求
     * @param url 路径
     * @param data 数据
     * @param option http选项
     * @returns {Promise<*>}
     */
    patch: (url: any, data?: any, option?: any) => Promise<void>;
    /**
     * put请求
     * @param url 路径
     * @param data 数据
     * @param option http选项
     * @returns {Promise<*>}
     */
    put: (url: any, data?: any, option?: any) => Promise<void>;
    /**
     * get请求
     * @param url 路径
     * @param data 数据
     * @param option http选项
     * @returns {Promise<*>}
     */
    get: (url: any, data?: any, option?: any) => Promise<void>;
    /**
     * delete请求
     * @param url 路径
     * @param data 数据
     * @param option http选项
     * @returns {Promise<*>}
     */
    delete: (url: any, data?: any, option?: any) => Promise<void>;
    /**
     * 终止请求
     *
     * */
    cancelSource: (url: any, msg?: string) => void;
};
/**
 * axios中JSON提交的config配置
 * @type {{headers: {Content-Type: string}}}
 */
export declare const JSONHeader: {
    headers: {
        'Content-Type': string;
    };
};
/**
 * axios中multipart/form-data提交的config配置
 * @type {{headers: {Content-Type: string}}}
 */
export declare const fileHeader: {
    headers: {
        'Content-Type': string;
    };
};
export default rkAxios;