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

@clgg/clgg-uni-request

v1.0.0

Published

uni-app 网络请求的封装 已适配openAPI的使用

Readme

clgg-uni-request

NPM version NPM downloads

介绍

clgg-uni-request 是对 uni-app 框架中 uni.request 网络请求方法的封装。封装目的:@umijs/openapi 根据 umi 中 request 请求 API 生成代码,不能适配 uni.request。

安装

npm install  @clgg/clgg-uni-request  --save
# or
pnpm add @clgg/clgg-uni-request
# or
yern add @clgg/clgg-uni-request

使用说明

调用

通过 import request from "@clgg/clgg-uni-request" 可以使用请求方法。 request 接收的 options 为 uni-request 的 config, 但排除 success、fail、complete、url 属性,除此之外还添加了两个可选属性 cancelToken、skipErrorHander;


// requst(url,option)

request('/api/user', {
  params: { name : 1 },
  timeout: 2000,
  // 是否跳过统一错误处理
  skipErrorHandler: true,

}

请求和响应拦截器

通过 import {addRequestInterceptor,addResponseInterceptor} from "@clgg/clgg-uni-request" 可以添加拦截器

import {
  addRequestInterceptor,
  addResponseInterceptor,
} from "@clgg/clgg-uni-request";

错误统一处理

通过 import {errorHandler} from "@clgg/clgg-uni-request" 处理错误。

import { errorHandler } from "@clgg/clgg-uni-request";
errorHandler((error) => {
  if (error.response) {
    // 请求成功发出且服务器也响应了状态码,但状态代码超出了 2xx 的范围
  } else if (error.name === "BizError") {
    // 状态码200 但接口数据为{succee:false,code:……}
  } else if (error.name === "ConnectionError") {
    //后端服务挂了或者 网路离线的情况
  }
});

请求取消

通过 import {CancelTokenSource} from "@clgg/clgg-uni-request" 来取消请求

import {CancelTokenSource} from "@clgg/clgg-uni-request";
const source = new CancelTokenSource();
request('/api/user', {
  params: { name : 1 },
  cancelToken:source
}
//取消任务
source.cancel();