本文整理汇总了TypeScript中request-promise.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: rp
it("no response_type parameter is present" + additionalTestDescription, () => {
if (withoutStateParam) {
delete params.state;
}
delete params.response_type;
return rp({
uri: authorizeEndpoint,
qs: params,
resolveWithFullResponse: true,
followRedirect: false,
}).then((data) => {
assert.fail();
}, (data: any) => {
let location = data.response.headers.location;
assert.equal(data.statusCode, 302);
assert.equal(data.response.headers.location.indexOf(redirectUri), 0);
let parsedUrl = url.parse(location, true);
if (withoutStateParam) {
assert.equal(parsedUrl.query.state, params.state);
}
assert.equal(parsedUrl.query.state, params.state);
assert.equal(parsedUrl.query.error, "invalid_request");
});
});
示例2:
}).then((response) => {
var cards = JSON.parse(response);
var card_to_move = [];
msg.send("Looking for your cards");
for(var i = 0; i < cards.length; i++){
for(var j = 0; j < cards[i].members.length; j++){
if(cards[i].members[j].username === username){
msg.send("cards found");
card_to_move.push(cards[i]);
}
}
}
if(card_to_move.length === 0){
msg.send("you don't have any card on paused");
}else{
msg.send("moving cards back to In Development list");
for(var i = 0; i < card_to_move.length; i++){
msg.send("moving card: " + card_to_move[i].name);
httpClient({
uri: "https://api.trello.com/1/cards/" + card_to_move[i].id +
"/idList?value=" + in_development_list_id + "&key=" + key + "&token=" + token,
method: "PUT"
}).then((response) => {
var card_moved = JSON.parse(response);
msg.send("card " + card_moved.name + " moved!");
}).catch((error) => {
msg.send("error: " + error);
});
}
}
}).catch((error) => {
示例3: getAccessToken
/**
* Return a particle access token.
*/
async function getAccessToken(): Promise<string> {
// Request options
let options = {
method: 'POST',
uri: 'https://api.particle.io/oauth/token',
auth: {
'user': PARTICLE_CLIENT_ID,
'pass': PARTICLE_CLIENT_SECRET,
},
form: {
'grant_type': 'refresh_token',
'refresh_token': PARTICLE_REFRESH_TOKEN,
}
};
// Fetch token
console.info('Fetching access token...')
let body = await request(options).catch((err) => {
console.error('Could not retrieve access token (HTTP ' + err.response.statusCode + ')')
console.error('Are your refresh token and client credentials correct?')
throw err;
});
// Parse response
let data = await json.parse(body);
return data.access_token;
}
示例4: expectJSON
it('/block/7 should exist', function() {
return expectJSON(rp('http://127.0.0.1:7781/blockchain/block/7', { json: true }), {
number: 7,
issuersCount: 2,
issuersFrame: 7,
issuersFrameVar: 4
});
});
示例5: Promise
return await new Promise((r, rj) => requestPromise({
method: 'POST',
uri: API,
strictSSL: false,
headers,
json: true,
body: sendData
}).then(r).catch(rj));
示例6: async
return async (method, path, body) => {
return await request({
method,
url: `http://localhost:${PORT}${path}`,
body,
json: true,
jar,
})
}
示例7: rp
checkSubscriberByEmail() {
const options = {
url: 'https://us8.api.mailchimp.com/3.0/lists/74a478b46d/members/' + md5(this.email),
method: 'GET',
headers: {
'Authorization': 'Basic ' + process.env.MAILCHIMP_API_KEY
}
}
return rp(options);
}
示例8: rb
.catch(function (err) {
logger.error(err, 'Error uploading dot file to imgur');
rb({
method: 'POST',
uri: responseURL,
body: {
text: config.messages.SystemMessages.UnexpectedSystemError,
response_type: config.slack.EPHEMERAL_RESPONSE_TYPE
},
json: true
});
})