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

lqy-axios-sdk

v1.0.11

Published

LQY-axios

Readme

lqy-axios-sdk 使用说明

基本用法

安装

npm install -S lqy-axios-sdk

lqy-axios 实例化

import lqyAxios from 'lqy-axios-sdk'

// lqyAxiosConfig 为可选类型
const request = new lqyAxios.default(axiosConfig,lqyAxiosConfig);

补充说明 axiosConfig

{
    "baseURL":"", // 公共路由
    "timeout":"", // 请求超时设定
    "headers":{}  // 请求头设定
}

补充说明 lqyAxiosConfig

// config 为 axios 本身 拦截器、响应器的配置信息上下文
{
  "validateStatus": validateStatus,
  "beforeInterceptorsResponseHook":(config)=>{}, // 响应器前 声明周期
  "beforeInterceptorsRequestHook":(config)=>{}, // 拦截器前 声明周期
  "afterInterceptorsResponseHook":(config)=>{}, // 响应器后 声明周期
  "afterInterceptorsRequestHook":(config)=>{} // 拦截器后 声明周期
}
lqyAxiosConfig 中 validateStatus
{
    "validateStatusFn":() => boolean, // 自定义 http 状态码判断,自定义是否请求成功
}

使用方法

基本使用


import lqyAxios from 'lqy-axios-sdk';

const request = new lqyAxios.default(axiosConfig);

async function xxx(){
    let res = await request.lqyRequest({
        url:'/xxx',
        method:'get/post'
    })
}

装饰器使用

import lqyAxios,{GET,POST} from 'lqy-axios-sdk';

const request = new lqyAxios.default(axiosConfig);

class test {
    // 装饰器会自动装配 请求格式,方便维护管理
    @GET('/xxx','接口备注')
    getTest(params){
        return request.lqyRequest(params)
    }
}

let testApi = new test();

async function xxx(){
    let res = await testApi.getTest({
        url:'/xxx',
    })
}

目前支持的 装饰器类型

  • GET
    • get 请求
  • POST
    • post 请求
  • PUT
    • put 请求
  • DELETE
    • delete 请求
  • UrlParam
    • 应对请求url /xx/xxx/{xxx} 情况
  • QS
    • 请求 data 序列化

请求参数类型

interface requestParams{
    url:string, // 接口地址
    method:string, // 请求类型
    params?:object, // params 传参
    data?:object // data 传参
    headers?:object // 定义配置 headers 类型
    [moreParams:string]:any, // 剩余参数
}

注意

使用 @UrlParam 与 @QS 时

当使用 @UrlParam 与 @QS 时,必须先使用 装饰器设置请求类型,如下

例子:

class test{
    constructor() {}

    @GET('/captchaImage')
    @QS
    @UrlParam
    getCode(params,additionalParam){
        return http.lqyRequest(params);
    }
}

let test01 = new test();

async function testFn(){
    let res = await test01.getCode({
        data:{
            name:'张三',
            age:27
        }
    },[666,'name']);
}
testFn();

当使用 @UrlParam 时

当使用 @UrlParam 时,除了需要提供 请求用的 params ,还需要提供 额外参数(additionalParam),additionalParam为数组格式。

路由会 根据数组索引顺序进行拼接。如下

async function testFn(){
    let res = await test01.getCode({
        data:{
            name:'张三',
            age:27
        }
    },[666,'name']);
}
testFn();

路由为 /captchaImage/666/name