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

app-lib-request

v1.0.14

Published

数据交互

Downloads

224

Readme

二、功能描述

  1. 基于axios
  2. 支持es和nodejs

三、注意事项

  1. 常见问题 请求跨越

    has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
  • 原因 请求头里的Host与Origin不一致 baseURL 设置了跨越

    Host:172.17.160.184:30201
    Origin:http://localhost:3334
  • 处理方式

        baseURL 往往设置作用于本工程的数据交互与其他静态文件等分开 用于便捷代理到后端服务 

六、API

Constants

Functions

CONFIG

配置信息

Kind: global constant

getConfig ⇒ Obejct

获取当前数据交互的配置

  • 不存在配置 则采用默认配置

Kind: global constant
Returns: Obejct - axios 配置信息

interceptors

拦截器

interceptors.request.use(function (config) {
   // 在发送请求之前做些什么
   return config;
 }, function (error) {
   // 对请求错误做些什么
   return Promise.reject(error);
 });
interceptors.response.use(function (response) {
  // 2xx 范围内的状态码都会触发该函数。
  // 对响应数据做点什么
  return response;
}, function (error) {
  // 超出 2xx 范围的状态码都会触发该函数。
  // 对响应错误做点什么
  return Promise.reject(error);
});

Kind: global constant

paramsSerializer(params)

过滤空参数

Kind: global function

| Param | Type | Description | | --- | --- | --- | | params | Object | 参数对象 |

bindMock(axiosConfig)

调整mock请求数据

Kind: global function

| Param | Type | | --- | --- | | axiosConfig | Object |

request(config) ⇒ Promise

完整的数据请求

  • 所有的便捷请求都会通过该请求

Kind: global function
Returns: Promise - Promise

| Param | Type | Description | | --- | --- | --- | | config | object | 请求配置 |

get(url, params, options) ⇒ Promise

get 请求

Kind: global function
Returns: Promise - 异步请求对象

| Param | Type | Description | | --- | --- | --- | | url | string | url地址 | | params | object | 参数 | | options | object | 配置 |

post(url, body, options) ⇒ Promise

post 请求

Kind: global function
Returns: Promise - 异步请求对象

| Param | Type | Description | | --- | --- | --- | | url | string | url地址 | | body | object | 请求体 | | options | object | 配置 |

put(url, body, options) ⇒ Promise

put 请求

Kind: global function
Returns: Promise - 异步请求对象

| Param | Type | Description | | --- | --- | --- | | url | string | url地址 | | body | object | 请求体 | | options | object | 配置 |

patch(url, body, options) ⇒ Promise

patch 请求

Kind: global function
Returns: Promise - 异步请求对象

| Param | Type | Description | | --- | --- | --- | | url | string | url地址 | | body | object | 请求体 | | options | object | 配置 |

del(url, body, options) ⇒ Promise

del 请求

Kind: global function
Returns: Promise - 异步请求对象

| Param | Type | Description | | --- | --- | --- | | url | string | url地址 | | body | object | 请求体 | | options | object | 配置 |

head(url, body, options) ⇒ Promise

head 请求

Kind: global function
Returns: Promise - 异步请求对象

| Param | Type | Description | | --- | --- | --- | | url | string | url地址 | | body | object | 请求体 | | options | object | 配置 |

copy(url, body, options) ⇒ Promise

copy 请求【axios 未实现 TODO 扩展】

Kind: global function
Returns: Promise - 异步请求对象

| Param | Type | Description | | --- | --- | --- | | url | string | url地址 | | body | object | 请求体 | | options | object | 配置 |

upload(url, body, options) ⇒ Promise

upload 上传 [TODO]

Kind: global function
Returns: Promise - 异步请求对象

| Param | Type | Description | | --- | --- | --- | | url | string | url地址 | | body | object | 请求体 | | options | object | 配置 |

download(url, body, options) ⇒ Promise

下载 TODO

  1. 直接url地址
  2. 流的形式

Kind: global function
Returns: Promise - 异步请求对象

| Param | Type | Description | | --- | --- | --- | | url | string | url地址 | | body | object | 请求体 | | options | object | 配置 |