2.4.0 • Published 5 years ago
xu-api v2.4.0
xu-api
创建工具 api.js
// 引入npm
const Api = require('xu-api')
// 定义接口地址
const host = 'http://127.0.0.1:8000/api/v1'
// 定义是否缓存接口返回的数据
const cache = false;
const api = new Api(host,cache)
module.exports = api
使用工具
// 引入api工具 封装了get,post,put,del 默认10000毫秒超时
const api = require('./api');
// GET请求
const get = await api.get('/item',{
id : 1
});
// POST请求
const post = await api.post('/item',{
name : 'test'
})
// PUT请求
const put = await api.put('/item',{
id : 1,
name : 'test update'
})
// DELETE请求
const del = await api.del('/item',{
id : 1
})
1.1.0 加入缓存
2.1.0 加入headers
2.2.0 全局headers new Api('http://host',{headers})
2.2.4 修复bug
2.3.0 加入node-fetch 支持node环境
2.3.4 修复bug
2.4.0 加入patch方法
2.4.0
5 years ago
2.3.4
5 years ago
2.3.3
5 years ago
2.3.2
5 years ago
2.3.1
5 years ago
2.3.0
5 years ago
2.2.4
5 years ago
2.2.3
5 years ago
2.2.2
5 years ago
2.2.1
5 years ago
2.2.0
5 years ago
2.1.0
5 years ago
1.2.0
5 years ago
1.1.2
5 years ago
1.1.1
6 years ago
1.0.9
6 years ago
1.0.8
6 years ago
1.0.7
6 years ago
1.0.6
6 years ago
1.0.5
6 years ago
1.0.4
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago