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

cnfapi

v2.1.4

Published

A lib project with ziu

Readme

cnfapi


author: bugszhou | Email:[email protected] description: A lib project with ziu

cnfapi是基于axios的小程序http库

Features

  • 支持 promise API
  • 拦截请求和响应
  • 自动转换 JSON 数据

安装

npm install -S cnfapi-miniprogram

Example

import Api from 'cnfapi-miniprogram';

const api = new Api({
  baseURL: 'https://prj1.demo.com',
  env: 'browser', // 使用环境:browser - 浏览器
  timeout: 10000, // 10s超时
  headers: {
    'Content-Type': 'application/json',
  },
  resSuccessCallback(data, next) {
    // next接受3个参数
    // 第一个参数是代表error
    // 第二个参数是代表传递给 resolve 的数据
    // 第三个参数是自定义数据
    if (data.code === 200) {
      next(null, data.data, data.code);
    } else {
      next({
        msg: data.msg,
        retcode: data.code,
      }, {}, data.code);
    }
  },
}, {
     getList: {
       interval: 2000, // 每隔2秒重试一次
       retryTimes: 10, // 重试10次
       apiName: '/test/prj/getList', // 接口pathurl
       desc: '', // 接口描述
       method: 'POST',
       params: {
         // post参数
         post: [{
            param: 'param1', // 参数名
            isNeed: 1, // 是否必须 1 为必须、0为非必须
         }],
         // get参数
         get: [{
           param: 'param2', // 参数名
           isNeed: 0, // 是否必须 1 为必须、0为非必须
        }],
       },
     },
     // restful模式
     getOrders: {
       interval: 2000, // 每隔2秒重试一次
       retryTimes: 10, // 重试10次
       apiName: '/test/prj/getOrders/{orderid}', // 接口pathurl
       desc: '', // 接口描述
       method: 'POST',
       params: {},
     },
   });

   // http请求调用方式
   // 1. 常规方式
   api.getList({
     data: {
       param1: 'param1',
       param2: 'param2',
     }
   })
   .then(({ data }) => {
     // 服务端数据
     console.log(data);
   })
   .catch(err => {
     console.log(err);
   });
   // 2. restful方式
   api.getOrders({
     restful: {
       orderid: 'param1',
     }
   })
   .then(({ data }) => {
     // 服务端数据
     console.log(data);
   })
   .catch(err => {
     console.log(err);
   });

request拦截器

api._before = function _before(apiOpts, apiConf, next) {
  // apiOpts为调用时传入的参数,如:
  /*
  {
    data: {
      param1: 123
    }
  }
  */
  // apiConf 该接口调用的配置参数
  // 可在_before内对参数做处理
  next(apiOpts);
};