• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript unirest.post函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中unirest.post函数的典型用法代码示例。如果您正苦于以下问题:TypeScript post函数的具体用法?TypeScript post怎么用?TypeScript post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了post函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: ImposterBuilder

 unirest.delete('http://localhost:2525/imposters').end(() => {
     unirest.post('http://localhost:2525/imposters').send(
         JSON.stringify(new ImposterBuilder()
             .port(port)
             .addStub(new StubBuilder()
                 .addResponses(new ResponseBuilder().status(222).build()).build())
             .build()))
         .end(() => {
             done();
         });
 });
开发者ID:njenan,项目名称:turbulence,代码行数:11,代码来源:IntegrationTestTurbulence.ts


示例2: before

    before((done) => {
        client = new UnirestHttpClient();

        unirest.post('http://localhost:2525/imposters')
            .send(JSON.stringify(
                {
                    port: 4545,
                    protocol: 'http',
                    stubs: [
                        {
                            predicates: [{equals: {headers: {headerOne: 'valueOne'}, method: 'GET'}}],
                            responses: [{is: {body: 'Get response', statusCode: 200}}]
                        },
                        {
                            predicates: [{
                                equals: {
                                    body: 'post rawBody',
                                    headers: {headerTwo: 'valueTwo'},
                                    method: 'POST'
                                }
                            }],
                            responses: [{is: {body: 'Post response', statusCode: 201}}]
                        },
                        {
                            predicates: [{
                                equals: {
                                    body: 'put rawBody',
                                    headers: {headerThree: 'valueThree'},
                                    method: 'PUT'
                                }
                            }],
                            responses: [{is: {body: 'Put response', statusCode: 202}}]
                        },
                        {
                            predicates: [{equals: {headers: {headerFour: 'valueFour'}, method: 'HEAD'}}],
                            responses: [{is: {body: 'Head response', statusCode: 203}}]
                        },
                        {
                            predicates: [{equals: {headers: {headerFive: 'valueFive'}, method: 'DELETE'}}],
                            responses: [{is: {statusCode: 204}}]
                        },
                        {
                            responses: [{is: {statusCode: 205}}]
                        }
                    ]
                }
            ))
            .end(() => {
                done();
            });
    });
开发者ID:njenan,项目名称:turbulence,代码行数:51,代码来源:IntegrationTestUnirestHttpClient.ts


示例3: Error

 return new Promise<number>((resolve, reject) => {
     unirest
         .post(`https://www.aliemu.com/wp-json/wp/v3/users/${userID}`)
         .headers(HEADERS)
         .type('json')
         .send(data)
         .end(
             res =>
                 res.error
                     ? reject(
                           new Error('Updating user in database failed.')
                       )
                     : resolve(200)
         );
 });
开发者ID:AcademicLifeInEM,项目名称:slackbot,代码行数:15,代码来源:aliemu.ts


示例4:

 var submitGame = (winPhoneArr: Array<string>, losePhoneArr: Array<string>, mvpPhone: string)=> {
     var jsss = JSON.stringify({
         "winUsers": winPhoneArr,
         "loseUsers": losePhoneArr,
         "key": '140fe1da9eab651944c',
         "mvp": [mvpPhone],
         "secret": 'jZae727K08KaOmKSgOaGzww/XVqGr/PKEgIMkjrcbJI='
     });
     unirest.post('http://api.yuanqi.tv/ladder/enroll_result')
         .headers({'Accept': 'application/json', 'Content-Type': 'application/json'})
         .send({
             "content": jsss
         })
         .end(function (response) {
             console.log(response, response.body);
         });
 };
开发者ID:solpie,项目名称:yqzb3,代码行数:17,代码来源:AdminRouter.ts


示例5: run

    run(testPlans: Array<TestPlan>, http: HttpClient): Q.Promise<SummaryResults> {
        let deferred = Q.defer<SummaryResults>();

        unirest.post('http://localhost:7777')
            .headers({'Accept': 'application/json', 'Content-Type': 'application/json'})
            .send(JSON.stringify(testPlans))
            .end((resp) => {
                resp.body.requests.forEach((request) => {
                    this.reporter.addResult(request);
                });

                for (let i = 0; i < resp.body.errors; i++) {
                    this.reporter.addError();
                }

                deferred.resolve(null);
            });

        return deferred.promise;
    }
开发者ID:njenan,项目名称:turbulence,代码行数:20,代码来源:RemoteExecutor.ts


示例6: resolve

 return new Promise<number>(resolve => {
     unirest
         .post('https://api.sendgrid.com/v3/mail/send')
         .header('Authorization', `Bearer ${process.env.SENDGRID_API_KEY}`)
         .type('json')
         .send({
             personalizations: {
                 to: [
                     {
                         email: recipient,
                     },
                 ],
             },
             from: {
                 email: '[email protected]',
             },
             template_id: availableTemplates[templateName],
         })
         .end(response => {
             resolve(response.statusCode);
         });
 });
开发者ID:AcademicLifeInEM,项目名称:slackbot,代码行数:22,代码来源:email.ts


示例7: verify

export function verify(req: express.Request, res: express.Response, next: Function) {
    unirest.post("https://gruntroll-military-verification-v1.p.mashape.com/verify/active")
        .header("X-Mashape-Key", process.env.MASHAPE)
        .header("Content-Type", "application/x-www-form-urlencoded")
        .header("Accept", "text/plain")
        .send(`date=${req.body.date}`)
        .send(`dob=${req.body.dob}`)
        .send(`name=${req.body.name}`)
        .end((result) => {
            let obj = JSON.parse(result.body);
            if (obj.error != null) {
                console.log(obj.error);
                console.log(obj.message);
                return next({ message: obj.message });
            }
            if (obj.is_active > 0 || obj.is_veteran > 0) {
                User.findOneAndUpdate({ _id: req['payload']._id }, { $set: { verified: true } }, { new: true }, (err, user) => {
                    if (err) return next({ message: "The verification process is expired or unauthorized" });
                    if (user.email) {
                        let mailOptions = {
                            from: 'Veteran Connect <[email protected]>',
                            to: user.email,
                            subject: `Welcome to Veteran Connect, ${user.firstName}!`,
                            html: welcome(user)
                        };
                        transporter.sendMail(mailOptions, (err) => {
                            if (err) {
                                console.log(err);
                                return next(err);
                            }
                        })
                    }
                    res.json({ token: user.generateJWT() });
                })
            } else if (obj.is_active == 0 && obj.is_veteran == 0) {
                return next({ message: "Unable to verify your service!" });
            }
        });
}
开发者ID:aurbina83,项目名称:veteranconnect,代码行数:39,代码来源:controller.ts


示例8: function

adminRouter.get('/test', function (req: any, res: any) {
    var unirest = require('unirest');
    // var jsss = JSON.stringify({
    //     "winUsers": [10082, 10082, 10082, 10082],
    //     "loseUsers": [10082, 10082, 10082, 10082],
    //     "mvp": [10082]
    // });

    // var jsss = JSON.stringify({
    //     "winUsers": ["15502168938"],
    //     "loseUsers": ["15692173023"],
    //     "key": '140fe1da9eab651944c',
    //     "secret": 'jZae727K08KaOmKSgOaGzww/XVqGr/PKEgIMkjrcbJI=',
    //     "mvp": ["10082"]
    // });

    var jsss = JSON.stringify({
        "winUsers": ["13616542277"],
        "loseUsers": ["15692173023"],
        "key": '140fe1da9eab651944c',
        "secret": 'jZae727K08KaOmKSgOaGzww/XVqGr/PKEgIMkjrcbJI='
    });
    unirest.post('http://api.yuanqi.tv/ladder/enroll_result')
        .headers({'Accept': 'application/json', 'Content-Type': 'application/json'})
        .send({
            "content": jsss
        })
        .end(function (response) {
            console.log(response, response.body);
        });

    var submitGame = (winPhoneArr: Array<string>, losePhoneArr: Array<string>, mvpPhone: string)=> {
        var jsss = JSON.stringify({
            "winUsers": winPhoneArr,
            "loseUsers": losePhoneArr,
            "key": '140fe1da9eab651944c',
            "mvp": [mvpPhone],
            "secret": 'jZae727K08KaOmKSgOaGzww/XVqGr/PKEgIMkjrcbJI='
        });
        unirest.post('http://api.yuanqi.tv/ladder/enroll_result')
            .headers({'Accept': 'application/json', 'Content-Type': 'application/json'})
            .send({
                "content": jsss
            })
            .end(function (response) {
                console.log(response, response.body);
            });
    };


    /////////////
    var isNoPhone = false;
    var gameArr = [];
    var getBluePhoneArr = (playerDocArr, start = 0)=> {
        var a = [];
        for (var i = start; i < 4 + start; i++) {
            var playerDoc = playerDocArr[i];
            if (!playerDoc['phone']) {
                isNoPhone = true;
                console.log('no phone ', playerDoc.name);
            }
            else
                a.push(playerDoc.phone + "");
        }
        return a;
    };

    var getRedPhoneArr = (playerDocArr)=> {
        return getBluePhoneArr(playerDocArr, 4);
    };

    for (var i = 0; i < 14; i++) {
        var gameDoc = db.game.dataMap[43001 + i];
        var winPhoneArr = [];
        var losePhoneArr = [];
        var playerDocArr = db.player.getDocArr(gameDoc.playerIdArr);
        console.log('playerDocArr ', playerDocArr);
        if (gameDoc.isBlue) {
            winPhoneArr = getBluePhoneArr(playerDocArr);
            losePhoneArr = getRedPhoneArr(playerDocArr);
        }
        else {
            losePhoneArr = getBluePhoneArr(playerDocArr);
            winPhoneArr = getRedPhoneArr(playerDocArr);
        }
        var mvpPhone;
        if (db.player.dataMap[gameDoc.mvp]['phone'])
            mvpPhone = db.player.dataMap[gameDoc.mvp].phone + "";

        console.log('winPhoneArr', winPhoneArr, 'losePhoneArr', losePhoneArr, 'mvp', mvpPhone);
        gameArr.push(gameDoc);
        // submitGame(winPhoneArr, losePhoneArr, mvpPhone);
    }
    console.log(gameArr);
    if (isNoPhone)
        res.send('no phone');
    else
        res.send("ok")
});
开发者ID:solpie,项目名称:yqzb3,代码行数:99,代码来源:AdminRouter.ts



注:本文中的unirest.post函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript unist-builder.default函数代码示例发布时间:2022-05-25
下一篇:
TypeScript unirest.get函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap