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


TypeScript request-promise.default函數代碼示例

本文整理匯總了TypeScript中request-promise.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了default函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: rp

                it("no response_type parameter is present" + additionalTestDescription, () => {
                    if (withoutStateParam) {
                        delete params.state;
                    }

                    delete params.response_type;

                    return rp({
                        uri: authorizeEndpoint,
                        qs: params,
                        resolveWithFullResponse: true,
                        followRedirect: false,
                    }).then((data) => {
                        assert.fail();
                    }, (data: any) => {
                        let location = data.response.headers.location;
                        assert.equal(data.statusCode, 302);
                        assert.equal(data.response.headers.location.indexOf(redirectUri), 0);

                        let parsedUrl = url.parse(location, true);
                        if (withoutStateParam) {
                            assert.equal(parsedUrl.query.state, params.state);
                        }
                        assert.equal(parsedUrl.query.state, params.state);
                        assert.equal(parsedUrl.query.error, "invalid_request");
                    });
                });
開發者ID:kamilbiela,項目名稱:auth360-backend,代碼行數:27,代碼來源:authorization.spec.ts

示例2:

		}).then((response) => {
			var cards = JSON.parse(response);
			var card_to_move = [];
			msg.send("Looking for your cards");
			for(var i = 0; i < cards.length; i++){
				for(var j = 0; j < cards[i].members.length; j++){
					if(cards[i].members[j].username === username){
						msg.send("cards found");
						card_to_move.push(cards[i]);
					}
				}
			}
			if(card_to_move.length === 0){
				msg.send("you don't have any card on paused");
			}else{
				msg.send("moving cards back to In Development list");
				for(var i = 0; i < card_to_move.length; i++){
					msg.send("moving card: " + card_to_move[i].name);
					httpClient({
						uri: "https://api.trello.com/1/cards/" + card_to_move[i].id + 
						"/idList?value=" + in_development_list_id + "&key=" + key + "&token=" + token,
						method: "PUT"
					}).then((response) => {
						var card_moved = JSON.parse(response);
						msg.send("card " + card_moved.name + " moved!");
					}).catch((error) => {
						msg.send("error: " + error);
					});	
				}
			}
		}).catch((error) => {
開發者ID:DouglasPonce85,項目名稱:acklen-slackbot,代碼行數:31,代碼來源:trelloBRB.ts

示例3: getAccessToken

/**
 * Return a particle access token.
 */
async function getAccessToken(): Promise<string> {
    // Request options
    let options = {
        method: 'POST',
        uri: 'https://api.particle.io/oauth/token',
        auth: {
            'user': PARTICLE_CLIENT_ID,
            'pass': PARTICLE_CLIENT_SECRET,
        },
        form: {
            'grant_type': 'refresh_token',
            'refresh_token': PARTICLE_REFRESH_TOKEN,
        }
    };

    // Fetch token
    console.info('Fetching access token...')
    let body = await request(options).catch((err) => {
        console.error('Could not retrieve access token (HTTP ' + err.response.statusCode + ')')
        console.error('Are your refresh token and client credentials correct?')
        throw err;
    });

    // Parse response
    let data = await json.parse(body);
    return data.access_token;
}
開發者ID:axxe,項目名稱:watertemp,代碼行數:30,代碼來源:logger.ts

示例4: expectJSON

 it('/block/7 should exist', function() {
   return expectJSON(rp('http://127.0.0.1:7781/blockchain/block/7', { json: true }), {
     number: 7,
     issuersCount: 2,
     issuersFrame: 7,
     issuersFrameVar: 4
   });
 });
開發者ID:duniter,項目名稱:duniter,代碼行數:8,代碼來源:branches2.ts

示例5: Promise

 return await new Promise((r, rj) => requestPromise({
   method: 'POST',
   uri: API,
   strictSSL: false,
   headers,
   json: true,
   body: sendData
 }).then(r).catch(rj));
開發者ID:martin-liu,項目名稱:m-sails,代碼行數:8,代碼來源:WrapperService.ts

示例6: async

 return async (method, path, body) => {
   return await request({
     method,
     url: `http://localhost:${PORT}${path}`,
     body,
     json: true,
     jar,
   })
 }
開發者ID:Majavapaja,項目名稱:Mursushakki,代碼行數:9,代碼來源:Mursushakki.spec.ts

示例7: rp

 checkSubscriberByEmail() {
     const options = {
         url: 'https://us8.api.mailchimp.com/3.0/lists/74a478b46d/members/' + md5(this.email),
         method: 'GET',
         headers: {
             'Authorization': 'Basic ' + process.env.MAILCHIMP_API_KEY
         }
     }
     return rp(options);
 }
開發者ID:slamby,項目名稱:slamby-website,代碼行數:10,代碼來源:mailchimp.service.ts

示例8: rb

 .catch(function (err) {
     logger.error(err, 'Error uploading dot file to imgur');
     rb({
         method: 'POST',
         uri: responseURL,
         body: {
             text: config.messages.SystemMessages.UnexpectedSystemError,
             response_type: config.slack.EPHEMERAL_RESPONSE_TYPE
         },
         json: true
     });
 })
開發者ID:ObjectiveTruth,項目名稱:Graphvizzer,代碼行數:12,代碼來源:createImgurLinkForDotString.ts


注:本文中的request-promise.default函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。