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

@xyzi/request

v3.1.4

Published

* request为uni-app的vue3项目、web的vue3项目中的常规请求插件。 * API为组合式API风格,其中浏览器兼容性同步vue3。 * 支持请求前置执行/后置执行/异常执行/完成执行 * 使用Typescript重构,有更友好的语法提示 * 基础API是默认参数及方法,动态参数及扩展返回 * 需先创建 createReqeust ,后使用 useRequest

Downloads

17

Readme

request

  • request为uni-app的vue3项目、web的vue3项目中的常规请求插件。
  • API为组合式API风格,其中浏览器兼容性同步vue3。
  • 支持请求前置执行/后置执行/异常执行/完成执行
  • 使用Typescript重构,有更友好的语法提示
  • 基础API是默认参数及方法,动态参数及扩展返回
  • 需先创建 createReqeust ,后使用 useRequest

文档

当前文档

3.X文档

历史文档

入门

引入

npm install @xyzi/request
  • main.js
import { createRequest } from '@xyzi/request'

createRequest(function(args) {
	// 自定义请求
})

使用

<script setup>
	import { useRequest } from '@xyzi/request'
	const {
		request, //请求方法
		option, //请求参数reactive
		state, //响应参数ref
		isLoading, //是否请求中ref
		isError, //是否失败ref
	} = useRequest(() => ({
		option: { //请求参数初始化
			url: "/",
			data: {},
		},
		state: [] //响应参数初始化
		isLoading: false //是否请求中初始化
	}))
 </script>

动态参数

| 名称 | 描述 | 版本 | |-- |-- |-- | |lifetime | 执行阶段 | 3.0.0 | |debounce | 防抖请求 | 3.0.0 | |throttle | 节流请求 | 3.0.0 | |lifecycle | 生命周期钩子执行请求 | 3.0.0 | |watchOption | 监听 option 执行请求 | 3.0.0 | |watchtruly | 监听函数返回值为truly执行 | 3.0.0 | |emit | 发布订阅请求 | 3.0.0 | |loop | 轮询请求 | 3.0.0 | |retry | 错误重试请求 | 3.0.0 | |extra | 自定义参数、方法 | 3.0.0 | |getters | 计算属性 | 3.0.0 | |initOptions | 初始化参数 | 3.0.0 | |storage | 持久化参数 | 3.1.0 | |emitData | 发布订阅 option.data | 3.1.0 |

其他

uniapp

  • createRequest
createRequest((args) => new Promise((success, fail) => uni.request(Object.assign(args, { success, fail }))))
createRequest('upload', (args) => new Promise((success, fail) => uni.uploadFile(Object.assign(args, { success, fail }))))

axios

  • createRequest
createRequest((args) => axios(args))