本文整理汇总了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;未经允许,请勿转载。 |
请发表评论