Search Github

Sunday, June 20th, 20211 min read

Search Github using as small NodeJs program which accepts the search query from the user.

Visit CodeSandbox

const readline = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout,
});
const fetch = require('node-fetch');
readline.question('Enter query : ', (query) => {
  fetch(`https://api.github.com/search/repositories?q=${query}`)
    .then((response) => response.json())
    .then((data) => {
      let newdata = new Map();
      data.items.forEach((item) => {
        newdata.set(item.html_url, item.full_name);
      });
      console.log(newdata);
    });
 
  readline.close();
});