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

@zebra-ui/uniapp-axios

v1.1.0

Published

axios适配器,在uniapp中使用axios,与axios对齐。

Downloads

4

Readme

zebra-ui-uniapp-axios

NPM version npm download

axios adapter for uni-app.

安装

$ npm install --save @zebra-ui/uniapp-axios axios

使用

// request.js
import axios from 'axios'
import uniAdapter from '@zebra-ui/uniapp-axios'

// create an axios instance
const service = axios.create({
  adapter: uniAdapter,
  baseURL: 'http://127.0.0.1:8080', // url = base url + request url
  // withCredentials: true, // send cookies when cross-domain requests
  timeout: 5000 // request timeout
})

export default service

发起请求

// api.js
import request from "./utils/request";

export function postData(data) {
  return request({
    url: '/your/api/url',
    method: 'POST',
    data
  })
}

与axios使用无差别。

差异

配置config

默认使用uni.request发起请求,但在特定条件下会自动变换成uni.uploadFileuni.downloadFile

| 参数 | 类型 | 默认值 | 说明 | | ------------------ | ------------------------- | ---------- | --------------------------------------------------------------------------------------------------- | | adapter | Function | uniAdapter | 自定义适配器 | | baseURL | String | | 基础地址 | | url | String | | 请求地址 | | method | String | get | 请求方法 | | params | Object | | 请求参数 | | data | String/Object/ArrayBuffer | | 请求数据 | | headers | Object | | 请求头,当Header中Content-Type赋值为multipart/form-data时会自动使用uni.uploadFile | | paramsSerializer | Function | | 在Get请求时会自动将params赋值给uni-app的data | | cancelToken | Object | | 取消令牌 | | timeout | Number | 5000 | 超时时间 | | responseType | String | Json | 会直接将该值自动赋值给uni中的dataType,但同时赋值给uni中的responseType,非arraybuffer时全都转为text | | sslVerify | Boolean | true | 增加字段,等同uni-app配置 | | withCredentials | Boolean | false | 增加字段,等同uni-app配置 | | firstIpv4 | Boolean | false | 增加字段,等同uni-app配置 | | onDownloadProgress | Function | | 当该值赋值时且method为get时会自动使用uni.downloadFile | | onUploadProgress | Function | | 在使用uni.uploadFIle时生效 |