本文整理汇总了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();
});
});
示例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;
}
示例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();
});
});
示例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);
}
}
});
示例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);
}
}
示例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;
}