tank-http-client.js基于 Needle.js的 Http 客户端
tank-http-client.js 是一个基于 needle.js的 http 客户端。
-
特性
- 只支持node环境,浏览器不可运行
- 支持链式调用
- 单元测试已覆盖
- 具有完善的文档
-
安装
npm install tank-http-client.js
基本示例
//导入 const thc = require("tank-http-client.js") //设置基础URL地址 thc.setBaseUrl("http://localhost:3008") thc.get("/test") .query({id: 1}) .send() .then((res) => { console.log(res) }).catch(err => { console.error(err) }); //输出 ->{code: 200, method: 'GET', data: 'get_test', search: '1'} async () => { const res = await thc.get("/test") .query({id: 1}) .send() console.log(res) } //输出 ->{code: 200, method: 'GET', data: 'get_test', search: '1'}
更多示例
delete
//delete thc.delete("/test").query({id: 1}).send().then((res) => { //res: {code: 200, method: 'DELETE', data: 'delete_test', search: '1'} })
post,put,patch
//post support put patch // thc.put("/test").xxx.send() // thc.patch("/test").xxx.send() thc.post("/test") .query({id: 1}).data({first: "1", nickname: "wind"}).data({ name: "tank", nickname: "wind body" }).send().then((res) => { // res:{ // code: 200, // method: 'POST', // data: 'post_test', // search: '1', // params: {first: '1', nickname: 'wind body', name: 'tank'} // } })
文件上传
//upload thc.post("/upload").query({id: 1}) .file({ file1: path.join(__dirname, "tank.png"), file2: path.join(__dirname, "tank.png") }) .send() .then((res) => { }) //upload by buffer thc.post("/upload").query({id: 1}) .bufferFile({ file1: path.join(__dirname, "tank.png"), file2: path.join(__dirname, "tank.png") }) .send() .then((res) => { })
评论
tank-http-client.js基于 Needle.js的 Http 客户端
tank-http-client.js是一个基于needle.js的http客户端。特性 只支持node环境,浏览器不可运行 支持链式调用 单元测试已覆盖 具有完善的文档安装npminstallt
tank-http-client.js基于 Needle.js的 Http 客户端
0
Axios基于 Promise 的 HTTP 客户端
Axios,基于Promise的HTTP客户端,可以工作于浏览器中,也可以在node.js中使用。功能:从浏览器中创建XMLHttpRequest从node.js中创建http请求支持PromiseA
Axios基于 Promise 的 HTTP 客户端
0
Axios基于 Promise 的 HTTP 客户端
Axios,基于 Promise 的 HTTP 客户端,可以工作于浏览器中,也可以在 node.js
Axios基于 Promise 的 HTTP 客户端
0
FaradayRuby的HTTP 客户端
Faraday是一个Ruby的HTTP客户端开发库,提供了一个通用的接口,支持如下适配器:Net::HTTPExconTyphoeusPatronEventMachine示例代码:conn = Far
FaradayRuby的HTTP 客户端
0
IQHTTPServiceiOS 的 HTTP 客户端
IQHTTPService 是 iOS 的 HTTP 客户端,可以用很简单的方法创建 Web API
IQHTTPServiceiOS 的 HTTP 客户端
0
HttpfulPHP 的 HTTP 客户端
Httpful是一个简单的PHP5.3+的Http客户端。它的优点在高刻度性、简洁性、和灵活性,并提供基本的功能和灵活性帮助开发者完成工作,让功能易于实现。它有以下特征:可读的HTTP方法支持(GET
HttpfulPHP 的 HTTP 客户端
0