本文整理匯總了TypeScript中twit.get函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript get函數的具體用法?TypeScript get怎麽用?TypeScript get使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了get函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: reject
return new Promise<number[]>((resolve, reject) => {
this.client.get('blocks/ids', params, (err, data, res) => {
if (err) {
this.sendApiFailure(err, res);
reject(err);
return;
}
log.debug('blocks/ids: Got block ids:', data.ids.length);
resolve(data.ids);
});
});
示例2: getTwitterName
export async function getTwitterName(user: User): Promise<string> {
const [row] = await db.query('SELECT * FROM manygolf.players WHERE id=$1', [user.id]);
const twitterToken = row.twitter_token;
const twitterSecret = row.twitter_secret;
const twitterId = row.twitter_id;
if (!twitterId) {
return null;
}
const twit = new Twit({
consumer_key: process.env.TWITTER_API_KEY,
consumer_secret: process.env.TWITTER_API_SECRET,
access_token: twitterToken,
access_token_secret: twitterSecret,
});
const userResource = await twit.get('users/show', {user_id: twitterId} as Twit.Params);
const username: string = (userResource.data as any).screen_name;
return username;
}