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


TypeScript superagent.agent函數代碼示例

本文整理匯總了TypeScript中superagent.agent函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript agent函數的具體用法?TypeScript agent怎麽用?TypeScript agent使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了agent函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: gsUploadByPost

export async function gsUploadByPost(formData:any){
    // expects an object with formData( the file(s)),

    function gsUploadByPostErrorHandler(err:any){
        alert('An error occurred while posting the file to GenomeSpace');
    };

    function gsUploadByPostCompleteHandler(responseObj:any){
        if (typeof responseObj == "string"){
            responseObj = JSON.parse(responseObj);
        }
        let newWin = window.open(responseObj.completionUrl, "GenomeSpace Upload", "height=340px,width=550px");
        (newWin as any).focus();
    };
    let params = {
        url: jsuiRoot + '/postToGenomeSpace',  //server script to process data
        type: 'POST',
        crossDomain: true,
        success: gsUploadByPostCompleteHandler,
        error: gsUploadByPostErrorHandler,
        data: formData,
        //Options to tell JQuery not to process data or worry about content-type
        cache: false,
        contentType: false,
        processData: false
    };

    // $.ajax(params);

    let req = request.agent()
        .post(params.url, (err, res) => err ? params.error(err) : params.success(res))
        .send(params.data);
}
開發者ID:agarwalrounak,項目名稱:cbioportal-frontend,代碼行數:33,代碼來源:gsuploadwindow.ts

示例2: req

  static get req() {
    if (Tools.isNode) {
      //const agent = new http.Agent()
      //agent.maxSockets = 100

      return request
        .agent()
        //.use(sdebug(console.info))
        .set({ "Accept-Encoding" : "gzip,deflate" })
    }
    else {
      return request
    }
  }
開發者ID:mediapeers,項目名稱:chinchilla,代碼行數:14,代碼來源:tools.ts

示例3: constructor

  constructor(opts: {host: string, context?: string, username?: string, password?: string, authType?: AuthType}) {
    this.host = opts.host;
    opts.context = opts.context || '';
    if (opts.context.length && opts.context[0] !== '/') opts.context = '/' + opts.context;
    this.context = opts.context;
    this.username = opts.username;
    this.password = opts.password;
    this.authType = opts.authType || opts.username && 'basic' || 'no';
    if (this.authType === 'basic' && !(opts.username && opts.password)) {
      throw new Error('BasicAuth needs both of username and password');
    }

    this.client = superagent.agent();
    this.cookieAuth = this.makeCookieAuthPromise();
  }
開發者ID:heycalmdown,項目名稱:node-confluence,代碼行數:15,代碼來源:index.ts

示例4: require

// and https://github.com/visionmedia/superagent/blob/master/Readme.md

request
  .post('/api/pet')
  .send({ name: 'Manny', species: 'cat' })
  .set('X-API-Key', 'foobar')
  .set('Accept', 'application/json')
  .end((err, res) => {
    if (res.ok) {
      console.log('yay got ' + JSON.stringify(res.body));
    } else {
      console.log('Oh no! error ' + res.text);
    }
  });

var agent = request.agent();
agent
  .post('/api/pet')
  .send({ name: 'Manny', species: 'cat' })
  .set('X-API-Key', 'foobar')
  .set('Accept', 'application/json')
  .end((err, res) => {
    if (res.error) {
      console.log('oh no ' + res.error.message);
    } else {
      console.log('got ' + res.status + ' response');
    }
  });

// Plugins
var nocache = require('superagent-no-cache');
開發者ID:AlBlanc,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:superagent-tests.ts

示例5:

request
    .post('/api/pet')
    .send({name: 'Manny', species: 'cat'})
    .set('X-API-Key', 'foobar')
    .set('Accept', 'application/json')
    .agent(httpsAgent)
    .end((err, res) => {
        if (res.ok) {
            console.log('yay got ' + JSON.stringify(res.body));
        } else {
            console.log('Oh no! error ' + res.text);
        }
    });

const agent = request.agent();
agent
    .post('/api/pet')
    .send({name: 'Manny', species: 'cat'})
    .set('X-API-Key', 'foobar')
    .set('Accept', 'application/json')
    .end((err, res) => {
        if (res.error) {
            console.log('oh no ' + res.error.message);
        } else {
            console.log('got ' + res.status + ' response');
        }
    });

const callback = (err: any, res: request.Response) => {};
開發者ID:Crevil,項目名稱:DefinitelyTyped,代碼行數:29,代碼來源:superagent-tests.ts


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