Wednesday, 31 May 2017

Can I request OAuth token with async/await

I'm making a node twitter module in ES6 syntax using async/await, but I always get undefined from oauth.getOAuthRequestToken function. seems like I have to put callback function but since I'm using async/await I don't want to use callback. Is there any to do it?

let oauth = new OAuth(
    'https://api.twitter.com/oauth/request_token',
    'https://api.twitter.com/oauth/access_token',
    config.consumerKey, config.consumerSecret,
    '1.0', null, 'HMAC-SHA1'
)

async function twitter () {
    let token = await oauth.getOAuthRequestToken()
    console.log("token", token)
}

twitter()



via Phillip YS

No comments:

Post a Comment