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


TypeScript unirest.get函數代碼示例

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


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

示例1: searchEvents

		public searchEvents(options : searchEventOptions, 
			callback : (err: any, data: searchEventResults) => void)
		{
			var request = this.base_url + 'events/search?app_key='+ this.app_key;

			for(var i in options){
				
				request += '&';
				
				request += i + '=' + options[i];
			}
			
			unirest.get(request, (response : any, err : any) => {
				
				if(err){
					return callback(err, null);
				}

				xml2js.parseString(response.body, {explicitArray : false}, (err: any, parsed: any) => {
					
					if(err){
						return callback(err, null);
					}
					
					return callback(null, parsed);
				});
				
			});
			
		}
開發者ID:sedouard,項目名稱:eventful-node,代碼行數:30,代碼來源:eventful-node.ts

示例2: MountebankRequestLog

export function MountebankRequestLog(port) {
    let deferred = Q.defer();

    unirest.get('http://localhost:2525/imposters/' + port).end((res) => {
        deferred.resolve(res.body.requests);
    });

    return deferred.promise;
}
開發者ID:njenan,項目名稱:turbulence,代碼行數:9,代碼來源:MountebankRequestLog.ts

示例3: reject

        return new Promise<any>((resolve, reject) => {
            unirest.get(this.userInfoEndpoint).headers({ authorization: `Bearer ${accessToken}`}).as.json(res => {
                if (res.status >= 400) {
                    reject(res);
                } else {
                    resolve(res.body);
                }
            });

        });
開發者ID:workfel,項目名稱:vulcain-corejs,代碼行數:10,代碼來源:expressStsAuthentication.ts

示例4: reject

 return new Promise<WordPress.User>((resolve, reject) => {
     unirest
         .get(`https://www.aliemu.com/wp-json/wp/v2/users/${userID}`)
         .headers(HEADERS)
         .query('context=edit')
         .end(
             res =>
                 res.error
                     ? reject(new Error('Could not retrieve user.'))
                     : resolve(res.body)
         );
 });
開發者ID:AcademicLifeInEM,項目名稱:slackbot,代碼行數:12,代碼來源:aliemu.ts

示例5: resolve

 return new Promise<boolean>((resolve, reject) => {
     if (this.userInfoEndpoint) {
         resolve(true);
     } else {
         const openIdConfigUrl = `${this.authority.value}/.well-known/openid-configuration`;
         unirest.get(openIdConfigUrl).as.json(res => {
             if (res.status >= 400) {
                 reject(res);
             } else {
                 this.userInfoEndpoint = res.body.userinfo_endpoint;
                 resolve(true);
             }
         });
     }
 });
開發者ID:workfel,項目名稱:vulcain-corejs,代碼行數:15,代碼來源:expressStsAuthentication.ts

示例6: listCategories

		public listCategories(callback : (err: any, data: categoryResult[]) => void)
		{
			var request = this.base_url + '/categories/list?app_key='+ this.app_key;
			
			unirest.get(request, (response: any, err: any) => {
			
				if(err){
					return callback(err, null);
				}
				
				xml2js.parseString(response.body, {explicitArray : false}, (err: any, parsed: any) => {
					
					if(err){
						return callback(err, null);
					}
					
					return callback(null, parsed.categories.category);
				});
			});
		}
開發者ID:sedouard,項目名稱:eventful-node,代碼行數:20,代碼來源:eventful-node.ts

示例7: resolve

        return new Promise<DataSource>((resolve) => {
            let uri = this.createRequestUrl();

            try {
                let values: Map<string, ConfigurationItem>;

                let request = rest.get(uri)
                    .headers({ 'Accept': 'application/json' })
                    .timeout(timeoutInMs);

                request = this.prepareRequest(request);

                request.end(function (response) {
                    if (response.status === 200 && response.body) {
                        if (response.body.error) {
                            if (!Service.isDevelopment) {
                                Service.log.info(null, () => `HTTP CONFIG : error when polling properties on ${uri} - ${response.body.error.message}`);
                            }
                        }
                        else {
                            values = new Map<string, ConfigurationItem>();
                            let data = response.body;
                            data.value && data.value.forEach(cfg => values.set(cfg.key, cfg));
                            self.lastUpdate = Service.nowAsString();
                            self.mergeChanges(values);
                        }
                    }
                    else {
                        Service.log.info(null, () => `HTTP CONFIG : error when polling properties on ${uri} - ${(response.error && response.error.message) || response.status}`);
                    }
                    resolve((values && new DataSource(values.values())) || null);
                });
            }
            catch (e) {
                Service.log.info(null, () => `HTTP CONFIG : error when polling properties on ${uri} - ${e.message}`);
                resolve(null);
            }
        });
開發者ID:Zenasoft,項目名稱:vulcain-corejs,代碼行數:38,代碼來源:httpConfigurationSource.ts

示例8: resolve

        return new Promise<PollResult>( ( resolve ) =>
        {
            let uri = this.createRequestUrl();

            try {
                let values;

                let request = rest.get(uri)
                    .headers({ 'Accept': 'application/json' })
                    .timeout(timeoutInMs);

                request = this.prepareRequest(request);

                request.end(function (response) {
                    if (response.status === 200 && response.body) {
                        if (response.body.error) {
                            if (!System.isDevelopment) {
                                System.log.info(null, ()=>`HTTP CONFIG : error when polling properties on ${uri} - ${response.body.error.message}`);
                            }
                        }
                        else {
                            values = new Map<string, ConfigurationItem>();
                            let data = response.body;
                            data.value && data.value.forEach(cfg => values.set(cfg.key, cfg));
                            self.lastUpdate = moment.utc().format();
                        }
                    }
                    else {
                        System.log.info(null, ()=>`HTTP CONFIG : error when polling properties on ${uri} - ${(response.error && response.error.message) || response.status}`);
                    }
                    resolve(values && new PollResult(self, values));
                });
            }
            catch (e) {
                System.log.info(null, ()=>`HTTP CONFIG : error when polling properties on ${uri} - ${e.message}`);
                resolve(null);
            }
        } );
開發者ID:workfel,項目名稱:vulcain-corejs,代碼行數:38,代碼來源:httpConfigurationSource.ts


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