本文整理汇总了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);
});
});
}
示例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;
}
示例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);
}
});
});
示例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)
);
});
示例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);
}
});
}
});
示例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);
});
});
}
示例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);
}
});
示例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);
}
} );