本文整理匯總了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'))
}
});