當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript unirest.post函數代碼示例

本文整理匯總了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: 'admin@aliemu.com',
             },
             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 <info@veteranconnect.co>',
                            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;未經允許,請勿轉載。