本文整理汇总了TypeScript中meteor/http.HTTP类的典型用法代码示例。如果您正苦于以下问题:TypeScript HTTP类的具体用法?TypeScript HTTP怎么用?TypeScript HTTP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HTTP类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: init
public init() {
let oldest = new Date();
oldest.setHours(oldest.getHours() - 24);
let lfRecord = SolarSystems.findOne({_id: '0'});
if (lfRecord && lfRecord.lastFetch.getTime() > oldest.getTime()) {
return;
}
winston.info('System data is old, refetching...');
SolarSystems.remove({});
let res = HTTP.get(CREST_ENDPOINT + 'solarsystems/');
let data = JSON.parse(res.content);
for (let item of data['items']) {
SolarSystems.insert({
_id: '' + item.id,
name: item.name,
name_lower: item.name.toLowerCase(),
});
}
SolarSystems.insert({
_id: '0',
name: null,
name_lower: null,
lastFetch: new Date(),
});
}
示例2: function
checkTwitter: function (userId: string) {
check(userId, String);
this.unblock();
var result = HTTP.call("GET", "http://api.twitter.com/xyz",
{ params: { user: userId } });
if (result.statusCode === 200)
return true
return false;
}
示例3: call
public call(method: string, uri: string, options: HTTP.HTTPRequest): HTTP.HTTPResponse {
options.headers = options.headers || {};
options.headers['Authorization'] = this.options.headers['Authorization'];
options.headers['Accept'] = this.options.headers['Accept'];
if (uri.indexOf('http') !== 0) {
uri = CREST_ENDPOINT + uri;
}
return HTTP.call(method, uri, options);
}
示例4: full_data
export function full_data(id){
var out = [];
var url = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=sra&id='+id;
var result = HTTP.get(url, {timeout:30000});
if(result.statusCode==200) {
parseString(result.content,function(err,res){
if (err) console.log(err);
else {
out.push(res);
}
//Adding all the important data to the Mongo and showing exporting that to client
//Meteor.call('insert',res, function(err,re){});
});
} else {
console.log("Response issue: ", result.statusCode);
}
//Searches.insert(out);
return out;
}
示例5: full_data
SRAdata :function(sra){
//if(sra!="") {
var id = [];
var url = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=sra&term=' + sra;
var result = HTTP.get(url, {timeout: 30000});
if (result.statusCode == 200) {
parseString(result.content, function (err, res) {
if (err) console.log(err);
else {
console.log(res.eSearchResult.IdList[0].Id[0]);
id.push(res.eSearchResult.IdList[0].Id);
}
});
} else {
console.log("Response issue: ", result.statusCode);
}
Searches.insert({SRAid: id});
return full_data(id.join(','));
//}
},
示例6: function
HTTP.call('GET',url,{timeout: 50000}, function(err,res){
if (err) reject(err.reason);
else{
var id = [];
var json = JSON.parse(xmlToJson(res.content));
if (json.eSearchResult.IdList){
id.push(json.eSearchResult.IdList.Id)
var url1='http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=sra&id='+id.join(',');
HTTP.call('GET',url1,{timeout: 50000}, function(err,result){
if (err) reject(err.reason);
else{
var id2=[]
var json2 = JSON.parse(xmlToJson(result.content));
id2.push(json2.EXPERIMENT_PACKAGE_SET.EXPERIMENT_PACKAGE)
resolve({SRAid:id[0],Record:id2[0]})
}
});
}
else(reject('NOTHING AVAILABLE'))
}
});