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


TypeScript http.HTTP類代碼示例

本文整理匯總了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(),
    });
  }
開發者ID:paralin,項目名稱:evewaitlist,代碼行數:27,代碼來源:system.ts

示例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;
 }
開發者ID:Jeremy-F,項目名稱:DefinitelyTyped,代碼行數:9,代碼來源:meteor-tests.ts

示例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);
 }
開發者ID:paralin,項目名稱:evewaitlist,代碼行數:9,代碼來源:client.ts

示例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;
}
開發者ID:bharath-cchmc,項目名稱:meteor-geo,代碼行數:20,代碼來源:fulldata.ts

示例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(','));
     //}
 },
開發者ID:bharath-cchmc,項目名稱:meteor-geo,代碼行數:20,代碼來源:main.ts

示例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'))
     }
 });
開發者ID:bharath-cchmc,項目名稱:sra-interface,代碼行數:21,代碼來源:sra.ts


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