izk-restful-api
v2.0.2
Published
restful 风格的API客户端封装,依赖于axios,适用于node和browser环境
Downloads
3
Readme
izk-restful-api
restful 风格的API客户端封装,依赖于axios和izk-util. 适用于node和browser环境
浏览器使用示例:
<script type="text/javascript" src="./axios.min.js"></script>
<script type="text/javascript" src="./izkutil.min.js"></script>
<script type="text/javascript" src="./restfulapi.min.js"></script>
var apiMap = new RestfulApi({
schools:'http://mock.test.com/mock/:mockId/cdp/user/crowd/listCrowd'
});
console.log(apiMap);
apiMap.schools.get({mockId:123}).then(res=>{
console.log('数据请求结果',res);
})
NodeJs环境使用示例
var RestfulApi = require('../dist/restfulapi.min');
var apiMap = new RestfulApi({
schools:'http://mock.test.com/mock/:mockId/cdp/user/crowd/listCrowd'
});
console.log(apiMap);
apiMap.schools.get({mockId:123}).then(res=>{
console.log('数据请求结果',res.data);
})