Get latest tweet by Github Username - async/await

A simple demo to use superagent and rss parser to get the latest tweet of a person by Github username.

by Geshan Manandhar

HTML

<script src="https://unpkg.com/[email protected]/superagent.js"></script>

JavaScript

const request = window.superagent;

async function getLatestTweets() {
  const usernames = ['bdougie', 'abraham', 'RamiKrispin'];  
  try {
    const requests = usernames.map(username => {
      return request
      .get(`https://api.github.com/users/${username}`)
      .set('Accept', 'application/json');
    });

    const responses = await Promise.all(requests);
    
    for(const response of responses) {
      const responseData = response.body;
      console.log(`Twitter username for GitHub user ${responseData.login} is ${responseData.twitter_username}`)
    }

  } catch(err) {
		console.log(`Error occurred ${err.message}`, err);
  }
}


(async () => {
  console.log('Start');
  await getLatestTweets();
  console.log('Done!');
})();