@edu-fe/api

1.2.0 • Public • Published

@edu-fe/api

Axios based client for edu-fe team

Installing

Using npm:

$ npm i @edu-fe/api

Using yarn:

$ yarn add @edu-fe/api

Dependencies

非小程序内使用Axios

小程序内调用wx.request

Api

create

api.create(url, [options])

返回Promise对象

create options

{
	// 是否缓存相应数据
	// 若使用缓存,则不会再次请求
	cache: fasle,
	
	// 是否需要校验登录状态
	// 如果需要登录,会调用前置登录方法
	checkLogin: false,
	
	// 是否需要发送formData
	// 尽在POST请求时可用
	formData: false,

    // baseURL
    baseURL: 'https://dynamicedu.wps.cn/API_V2'
	
	// 任何axios可用的选项
	...
}

createModule

api.createModule(module, [name])

未传入name,则注册到common组中

错误处理

请求发生异常时会返回状态为rejected的Promise对象,需要在调用时catch

Example

import api from '@edu-fe/api'

const module = {
	request: api.create('/')
}
api.createModule(module, 'example')
api.example.request()
	.then(res => {
		// TODO:
	})
	.catch(err => {
		// handle error
	})

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.2.00latest

Version History

VersionDownloads (Last 7 Days)Published
1.2.00
1.1.60
1.1.50
1.1.40
1.1.30
1.1.20
1.1.10
1.1.00
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00
0.0.180
0.0.170
0.0.160
0.0.150
0.0.140
0.0.130
0.0.120
0.0.110
0.0.100
0.0.90
0.0.80
0.0.70
0.0.60
0.0.50
0.0.40
0.0.30
0.0.20
0.0.10

Package Sidebar

Install

npm i @edu-fe/api

Weekly Downloads

0

Version

1.2.0

License

none

Unpacked Size

5.75 kB

Total Files

8

Last publish

Collaborators

  • julywind
  • hungryyang
  • ccforeverd
  • shockw4ver