当前位置: 首页>>代码示例>>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;未经允许,请勿转载。