Giter VIP home page Giter VIP logo

tacos's Introduction

tacos

vxios的ts版本 支持自定义传入

修改日志

  • 去除了./core/processResult 改变了实例原型的用法 0.0.1-beta8

关于Tacos

设计这个mini库的初衷是为了统一管理微信的所有请求方法,目的是将所有微信与网络的请求统一Promise化,并且能与web端Axios进行相互迁移(仍在完善中),目前可以支持wxapp原生,uniapp,taro

特性

  • 支持Promise API
  • CommonJS模块规范
  • ES6书写风格
  • 拦截请求和响应
  • 集成所有wx请求
  • 开箱即用的取消请求

开始使用

Taro是一个基于微信请求封装的mini请求库

安装

//npm
npm i @gatomis/tacos -s
or
//yarn
yarn add @gatomis/tacos -s

引入项目

//来自./http.js
//创建实例

import Taro from '@tarojs/taro'
import tacos from '@gatomis/tacos'






//与vxios axios不同的是,tacos必须进行实例化后才能使用
const instance = tacos.create({
  baseURL: "https://m.shuyishuer.cn/api/v1/",
  http: Taro,//请求实例 可以切换成wx,uni,Taro 
  timeout:10000
})
//请求拦截器配置
instance.interceptors.request.use(async (config) => {
  return config

})
//响应拦截器配置
instance.interceptors.response.use((response) => {



}, error => {

}
)


//返回实例request
export default instance

使用请求

import  http from  './http.ts'
export function getType() {
    return http.request<Result<any>>({
        method: 'post',
        url: `content/category/combox`
    })

}

基于原型

本项目原型基于微信开发手册

licence

MIT License

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.