Get latest tweet by Github Username

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>
<script src="https://unpkg.com/[email protected]/dist/rss-parser.min.js"></script>

JavaScript

const request = window.superagent;
const parser = new RSSParser();
const CORS_PROXY = "https://cors-anywhere.herokuapp.com/"

request
  .get('https://api.github.com/users/abraham')
  .set('Accept', 'application/json')       
  .end((err, res) => {
  	if(!err) {
    	console.log('Twitter Username: ', res.body.twitter_username)
      
      parser.parseURL(`${CORS_PROXY}https://nitter.net/${res.body.twitter_username}/rss`, (err, feed) => {
        if (!err) {
        	console.log(`The last tweet by ${res.body.twitter_username} is - ${feed.items[0].title}`);
        }        
      });
    }  
  });

console.log('This would log first');