0.1.5 • Published 5 years ago

think-axios v0.1.5

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

think-axios

Install

# npm
npm install --save think-axios
# yarn
yarn add think-axios

Use

引入

// config/extend.js
const axios = require('think-axios')
module.exports = [
  model(think.app),
  axios(think.app,conf={})
]

使用

this.axios() 
this.httpGet()
this.httpPost()

think.axios() 
think.httpGet()
think.httpPost()

ctx.axios() 
ctx.httpGet()
ctx.httpPost()

service.axios() 
service.httpGet()
service.httpPost()

其他 axios 与 https://github.com/mzabriskie/axios 方法一致

httpGet , httpPost 经过简单封装,并且请求出错时,会打印log

const indexData = await this.httpGet(url, params, conf)
const indexData = await this.httpPost(url, params, conf)

返回数据格式

// 成功
{"errno":0,"errmsg":"","data":""}

// 失败
{"errno":1,"errmsg":"","data":""}
0.1.5

5 years ago

0.1.4

6 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago