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


TypeScript request.default方法代碼示例

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


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

示例1: request

                    let cardPromise = new Promise<teams.ComposeExtensionAttachment>((resolve, reject) => {
                        request(imageApiUrl, (error2, res2, body2) => {
                            // parse image url
                            if (!error2) {
                                let imageUrl = null;
                                let pages: [any] = JSON.parse(body2).query.pages;
                                if (pages && pages.length > 0 && pages[0].thumbnail) {
                                    imageUrl = pages[0].thumbnail.source;
                                } else {
                                    // no image so use default Wikipedia image
                                    imageUrl = "https://upload.wikimedia.org/wikipedia/commons/d/de/Wikipedia_Logo_1.0.png";
                                }

                                // highlight matched keyword
                                let highlightedTitle = wikiResult.title;
                                if (queryParameter) {
                                    let matches = highlightedTitle.match(new RegExp(queryParameter, "gi"));
                                    if (matches && matches.length > 0) {
                                        highlightedTitle = highlightedTitle.replace(new RegExp(queryParameter, "gi"), "<b>" + matches[0] + "</b>");
                                    }
                                }

                                // make title into a link
                                highlightedTitle = "<a href=\"https://en.wikipedia.org/wiki/" + encodeURI(wikiResult.title) + "\" target=\"_blank\">" + highlightedTitle + "</a>";

                                let cardText = wikiResult.snippet + " ...";

                                // create the card itself and the preview card based upon the information

                                // HeroCard extends ThumbnailCard so we can use ThumbnailCard as the overarching type
                                let card: builder.ThumbnailCard = null;
                                // check user preference for which type of card to create
                                if (session.userData.composeExtensionCardType === "thumbnail") {
                                    card = new builder.ThumbnailCard();
                                } else {
                                    // at this point session.userData.composeExtensionCardType === "hero"
                                    card = new builder.HeroCard();
                                }
                                card.title(highlightedTitle)
                                    .text(cardText)
                                    .images([new builder.CardImage().url(imageUrl)]);

                                // build the preview card that will show in the search results
                                // Note: this is only needed if you want the cards in the search results to look
                                // different from what is placed in the compose box
                                let previewCard = new builder.ThumbnailCard()
                                    .title(highlightedTitle)
                                    .text(cardText)
                                    .images([new builder.CardImage().url(imageUrl)]);

                                let cardAsAttachment: teams.ComposeExtensionAttachment = card.toAttachment();
                                // add preview card to the response card
                                cardAsAttachment.preview = previewCard.toAttachment();

                                // resolve this Promise for a card once all of the information is in place
                                resolve(cardAsAttachment);
                            }
                        });
                    });
開發者ID:gvprime,項目名稱:microsoft-teams-sample-complete-node,代碼行數:59,代碼來源:ComposeExtensionHandlers.ts

示例2: quitAndInstall

 public static quitAndInstall() {
     let options: request.OptionsWithUrl = {
         url: `${this.serviceUrl}/emulator/system/quitAndInstall`,
         method: "POST"
     };
     request(options);
 }
開發者ID:sarthakfx,項目名稱:BotFramework-Emulator,代碼行數:7,代碼來源:emulator.ts

示例3: zoomReset

 public static zoomReset() {
     let options: request.OptionsWithUrl = {
         url: `${this.serviceUrl}/emulator/window/zoomReset`,
         method: "POST"
     };
     request(options);
 }
開發者ID:sarthakfx,項目名稱:BotFramework-Emulator,代碼行數:7,代碼來源:emulator.ts

示例4: it

 it('should make the server ignore next middlewares for all services', (done) => {
     request('http://localhost:5674/ignoreEndpoint/withMiddlewares', (error, response, body) => {
         expect(body).to.eq('OK');
         expect(middlewareCalled).to.be.false;
         done();
     });
 });
開發者ID:thiagobustamante,項目名稱:typescript-rest,代碼行數:7,代碼來源:ignore-middlewares.spec.ts

示例5: shows

    shows(name:string,callback:(err:any,shows?:ITVShowSearchResult[]) => void) {
        let target = config.site1 + "search/" + encodeURIComponent(name);

        request(target,{},(err,res,body:string) => {
            if(err) {return callback(err);}

            let $ = cheerio.load(body);

            let results:ITVShowSearchResult[] = [];

            let pattern = "^\\s*(.+?) \\((\\d+)\\)\\s*Description: ([\\s\\S]+?)\\s*Latest Episode: Season (\\d+)[\\s\\S]*$";

            $("div.episode-summary > * > * > * > * > *").each((i,el) => {
                let rawData = $(el).text();
                let lastTitle = results[results.length - 1];

                let matchData = rawData.match(new RegExp(pattern,""));

                if(!matchData) {return;}

                results[results.length] = {
                    title: matchData[1],
                    seasons: parseInt(matchData[4]),
                    url: url.resolve(target,$(el).find("a").attr("href")),
                    year: parseInt(matchData[2])
                }
            });

            callback(null,results);
        })
    }
開發者ID:SwadicalRag,項目名稱:node-pftv-api,代碼行數:31,代碼來源:search.ts

示例6:

handler.on('status', event => {
	const state = event.state;
	switch (state) {
		case 'error':
		case 'failure':
			const commit = event.commit;
			const parent = commit.parents[0];

			// Fetch parent status
			request({
				url: `${parent.url}/statuses`,
				headers: {
					'User-Agent': 'misskey'
				}
			}, (err, res, body) => {
				if (err) {
					console.error(err);
					return;
				}
				const parentStatuses = JSON.parse(body);
				const parentState = parentStatuses[0].state;
				const stillFailed = parentState == 'failure' || parentState == 'error';
				if (stillFailed) {
					post(`**⚠️BUILD STILL FAILED⚠️**: ?[${commit.commit.message}](${commit.html_url})`);
				} else {
					post(`**🚨BUILD FAILED🚨**: →→→?[${commit.commit.message}](${commit.html_url})←←←`);
				}
			});
			break;
	}
});
開發者ID:ha-dai,項目名稱:Misskey,代碼行數:31,代碼來源:github.ts

示例7: it

 it('should return a referenced file', (done) => {
     request({
         url: 'http://localhost:5674/download/ref'
     }, function(error, response, body) {
         expect(_.startsWith(body.toString(),'\'use strict\';')).to.eq(true);
         done();
     });
 });
開發者ID:garyevari,項目名稱:typescript-rest,代碼行數:8,代碼來源:test.spec.ts


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