Skip to content

ickeep/think-axios

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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":""}

About

thinkjs3.0 axios

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published