• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript request.defaults函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中request.defaults函数的典型用法代码示例。如果您正苦于以下问题:TypeScript defaults函数的具体用法?TypeScript defaults怎么用?TypeScript defaults使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了defaults函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: makeRequest

function makeRequest(path, headers = {}) {
  const r = request.defaults({ proxy: "http://127.0.0.1:" + proxyPort });
  return new Promise(resolve => {
    r({ url: "http://localhost:" + port + path, headers }, function(
      error,
      response,
      body
    ) {
      resolve(body);
    });
  });
}
开发者ID:mattzeunert,项目名称:fromjs,代码行数:12,代码来源:ProxyInstrumenter.test.ts


示例2: constructor

 constructor(cookieJar:CookieJar) {
     this.requestWithJar = request.defaults({jar: cookieJar});
 }
开发者ID:SwadicalRag,项目名称:skyweb,代码行数:3,代码来源:status_service.ts


示例3:

import * as diag from '../core/diag';
import * as http from 'http';
import * as init from '../core/init';
import * as offline from './offline';
import * as request from 'request';
import * as roles from '../security/roles';
import * as server from '../security/server';
import * as urls from './urls';

// require request.js to manage cookies for us
let requestDefaults = {
  json: true,
  jar: true,
  withCredentials: true
};
let requestWithDefaults = request.defaults(requestDefaults);

/**
 * callback allowing customizing an object not immediately available at time of call.
 *
 * @param object for inspection or customization.
 * @return promise or object on same deferred object.
 */
export interface HttpCallback<T> {
  (value: T): Q.Promise<T> | T;
}

/**
 * type representing a raw request.
 */
export type HttpRequest = request.Request;
开发者ID:relution-io,项目名称:relution-sdk,代码行数:31,代码来源:http.ts


示例4: Promise

"use strict";

import * as request from "request";
import * as cheerio from "cheerio";

const KOA_MIDDLEWARES_PAGE = "https://github.com/koajs/koa/wiki";
const KOA_MIDDLEWARES_DEFINITION = "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/";

const http = request.defaults({
    headers: {
        'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36"
    }
});

export function getKoa2Middlewares (): PromiseLike<string[]> {
    return new Promise((resolve, reject) => {
        http.get(KOA_MIDDLEWARES_PAGE, (err, res, body) => {
            if (err) {
                reject(err);
            } else {
                const $ = cheerio.load(body);
                const middlewares = Array.from($('td[align="center"]'))
                    .filter(node => $(node).html() !== "")
                    .map(node => {
                        return $(node).prev().find('a').html()
                    });

                resolve(middlewares);
            }
        })
    })
开发者ID:hellopao,项目名称:koa2-middlewares,代码行数:31,代码来源:index.ts


示例5:

 * TODO: Don't reuse the same instance fo requestOptions for each call.
 */

import * as path from "path";
import * as url from "url";
import * as request from "request";
import * as util from "util";
import * as http from "http";

//==============================================================================
// Global request module defaults.
//==============================================================================

request.defaults({
  headers: {
    "Content-Type": "application/json"
  }
});

//==============================================================================
// Global constants.
//==============================================================================

export enum NEO4J_PROTOCOL { http, https };

// TODO: Change to enums
const NEO4J_ENTITY_TYPES: string[] = ["node", "relationship"];
const NEO4J_HTTP_METHODS: string[] = ["DELETE", "GET", "POST", "PUT"];
const NEO4J_RELATIONSHIP_DIRECTION: string[] = ["all", "in", "out"];

const NEO4J_STANDARD_PATHS: any = {
开发者ID:tpennetta,项目名称:neo4j-typescript,代码行数:31,代码来源:index.ts


示例6: constructor

 public constructor(logger: ILogger) {
     super();
     this.logger = logger;
     this.cookieJar = Request.jar();
     this.request = Request.defaults({ jar: this.cookieJar });
 }
开发者ID:anurse,项目名称:SignalR,代码行数:6,代码来源:NodeHttpClient.ts



注:本文中的request.defaults函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript request.del函数代码示例发布时间:2022-05-25
下一篇:
TypeScript request.default函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap