当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript request.get函数代码示例

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


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

示例1: it

 it('should be able to send 406', (done) => {
     request.get('http://localhost:5674/errors/notacceptable', function(error, response, body) {
         expect(response.statusCode).to.eq(406);
         done();
     });
 });
开发者ID:garyevari,项目名称:typescript-rest,代码行数:6,代码来源:test.spec.ts

示例2: getAComic

    // para: ids:string - id of comic, callback:function(error:string, response:string, body:string) => void - callback with a three string parameters
    // Given a comic id, get the associated JSON comic object from the database
    // return: none
    getAComic(comicId:string, callback:(error:string, response:string, body:string) => void) {

        var request = require('request');
        request.get('http://glacial-retreat-45891.herokuapp.com/comic/' + comicId, callback);
        return;
    }
开发者ID:tjxn,项目名称:CharBroiled,代码行数:9,代码来源:ComicWebService.ts

示例3: it

 it('has a working index page with SSL', done => {
   request.get({url: 'https://localhost:5001', rejectUnauthorized: false}, (error, response, body) => {
     expect(response.statusCode).to.equal(200);
     done();
   });
 });
开发者ID:svenkreiss,项目名称:databench,代码行数:6,代码来源:test.ts

示例4: Client

const pubKey = Bitcore.PrivateKey(tmp).toPublicKey() ;
const baseUrl = `https://api.bitcore.io/api/${coin}/${network}`;
let client = new Client({
  baseUrl,
  authKey: authKeyObj,
});

// utxos
// addresses

const url = `${baseUrl}/wallet/${pubKey}/${path}`;
console.log('[v8tool.37:url:]', url);
const signature = client.sign({ method: 'GET', url });
const payload = {};

request.get(url, {
  headers: { 'x-signature': signature },
  body: payload,
  json: true
}, (err, req, body) => {
  if (err) {
    console.log('[v8tool.43:err:]', err);
  } else {
    try {
console.log('[v8tool.50:body:]', body);
    } catch (e) {
console.log('[v8tool.52]', e, body);
    }
  }
});
开发者ID:bitpay,项目名称:bitcore,代码行数:30,代码来源:v8tool.ts

示例5: function

module.exports = function (callback) {
    const eventsUrl = `${firebaseConfig.databaseURL}/events.json?auth=${FirebaseAppSecret}`;
    const stateUrl = `${firebaseConfig.databaseURL}/state.json?auth=${FirebaseAppSecret}`;
    const maxWebtaskDuration = 25000;
    const interval = 1000;
    const newOrderChance = 0.3;

    var executionCount = maxWebtaskDuration / interval;

    request.get(stateUrl, getStateCallback);

    function getStateCallback(error, res, stateBody) {
        if (error) {
            callback(error);
        } else if (res.statusCode !== 200) {
            callback(res.body.error); 
        } else {
            const state: ScreenState = JSON.parse(stateBody);
            generateOrders(state);
        }
    }

    function generateOrders(state: ScreenState) {
        scheduleGenerateOrder();
        
        function generateOrder() {
            const event = Math.random() > newOrderChance
                ? randomCounteroffer()
                : randomOrder();
            const requestOptions = {
                method: 'POST',
                url: eventsUrl,
                json: event
            };
            request(requestOptions, scheduleGenerateOrder);
        }

        function randomCounteroffer() {
            console.log('Will add counteroffer');
            const index = randomInt(0, state.activeOrders.length - 1);
            const order = state.activeOrders[index];            
            return {
                    type: "AddOrderAction",
                    user: "Market Maker",
                    product: order.product,
                    quantity: 1,
                    price: order.price,
                    direction: 1 - order.direction,
                    timestamp: { '.sv': 'timestamp' }
            };
        }

        function randomOrder() {
            console.log('Will add new order');
            return {
                type: "AddOrderAction",
                user: "Market Maker",
                product: ['crystals', 'credits', 'mithril', 'mercury'][randomInt(0, 5)],
                quantity: randomInt(1, 1000),
                price: randomInt(1, 1000),
                direction: randomInt(0, 2) + 0,
                timestamp: { '.sv': 'timestamp' }
            };
        }

        function scheduleGenerateOrder() {
            if (executionCount-- > 0) {
                console.log(`Scheduling new order. ${executionCount} remaining.`);
            setTimeout(generateOrder, interval);
            } else {
                console.log('Sequence finished');
                callback(null, 'Finished');
            }
        }
    }

    function randomInt(min, max) {
        return Math.floor(Math.random() * (max - min) + min);
    }

}
开发者ID:DandiestSquare1,项目名称:tradux,代码行数:81,代码来源:market-maker.ts

示例6: getAllUsers

 // para: callback:function(error:string, response:string, body:string) => void - callback with a three string parameters
 // retrieve every single user in the mongo user database
 // return: none
 getAllUsers(callback:(error:string, response:string, body:string) => void) {
     var request = require('request');
     request.get('http://charbroiled-user-api.herokuapp.com/user/', callback);
     return;
 }
开发者ID:tjxn,项目名称:CharBroiled,代码行数:8,代码来源:UserWebService.ts


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