當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。