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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wbiokr/http

v2.3.9-temp

Published

基于axios实例

Downloads

209

Readme

1 参数

| Property | Type | 默认值 | Description | 是否必填 | | ----- | ------------- | ------------- | ------------------------ | ----- | | baseURL | String | '' | axios实例基础地质 | 当不存在环境变量的时候必填 | | timeout | Number | 0 | 超时时间 | false | | headers | Object | {} | 公共headers | false | | commonParams | Object | {} | 公共参数 | false | | dataKey | String | data | 响应内容主体 | false | | beforeRequest | null|Function(config) | null | 发起请求之前的配置处理钩子 | false | | error | null|Function(msg) | null | 200但响应内容为错误状态下的错误内容提示 | false | | logout | null|Function(config) | null | 错误码401时候的退出登录钩子 | false | | isOk | null|Function(config) | null | 验证响应内容是否为正确状态,默认匹配code、status是否为200或0 | false |

环境变量: 仅支持webpack环境
VUE环境变量:baseURL---VUE_APP_BASEURL teimout---VUE_APP_TIMEOUT
REACT环境变量:baseURL---REACT_APP_BASEURL teimout---REACT_APP_TIMEOUT

2 发送带取消的请求

2.1 如何发送请求

发送请求的时候,带cancelToken参数: post:请求可以使用Symbol; get:则可以使用时间搓;

2.2 如获取并取消请求

所有带有取消头的请求都会缓存在全局对象window.AXIOS_CANCELS下,使用传入的cancelToken则可以获取到取消函数,手动取消请求:

const cancelPostList = Symbol()
.......// 逻辑代码
window.AXIOS_CANCELS[cancelPostList] && window.AXIOS_CANCELS[cancelPostList]()

3 实例方法

| API | 参数 | 备注 | | ----- | ------------- | ------------- | | get | (url, params, headers) | 必填url | | post | (url, data, params, headers) | 必填url, params为query参数,data为body参数 | | postWWW | (url, data, params) | 必填url, params为query参数,data为body参数,headers会传入('Content-Type': 'application/x-www-form-urlencoded') | | postJson | (url, data, params) | 必填url, params为query参数,data为body参数,headers会传入('Content-Type': 'application/json') | | postForm | (url, data, params) | 必填url, params为query参数,data为body参数,headers会传入('Content-Type': 'multipart/form-data') | | put | (url, data, params, headers) | 必填url, params为query参数,data为body参数 | | deleteAction | (url, data, params, headers) | 必填url, params为query参数,data为body参数 | | getBlob | (url, params, headers) | 必填url, responseType: 'blob' | | postBlob | (url, data, params, headers) | 必填url, responseType: 'blob' | | download | (url, params, type='get', nameOrKey, headers) | 必填url, 当nameOrKey为完整的的名字时则作为名字下载,无值时取接口filename,有值无后缀时作为key取接口 |