<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          tank-http-client.js基于 Needle.js的 Http 客戶端

          聯(lián)合創(chuàng)作 · 2023-09-29 06:46

            tank-http-client.js 是一個基于 needle.js的 http 客戶端。

          • 特性

          •  只支持node環(huán)境,瀏覽器不可運行
          •  支持鏈式調(diào)用
          •  單元測試已覆蓋
          •  具有完善的文檔
          • 安裝

            npm install tank-http-client.js

            基本示例

            //導入
            const thc = require("tank-http-client.js")
            //設(shè)置基礎(chǔ)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) => {
            
                })
          瀏覽 16
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  欧美系列-熊猫成人网 | 国产女主播在线 | 翔田千里无码破解HD | 精品免费一区二区三区在线赤裸 | 欧美肉丝袜videos办公室 |