I wrote the following code in Node.js:
const axios = require("axios");
const prompt = require("prompt-sync")();
let numRepo = prompt("Welcome, How many repositories to search? ");
numRepo = parseInt(numRepo);
while (!Number.isInteger(numRepo))
numRepo = parseInt(prompt("Please insert integer: "));
let n;
if (numRepo < 100) n = 1;
else n = numRepo % 100;
axios
.get(
`https://api.github.com/search/repositories?q=language:js&sort=stars&order=desc&per_page=${numRepo}&page=${n}`
)
.then((response) => {
let repo = [];
response.data.items.forEach((e) => repo.push(e));
console.log(repo);
})
.catch((error) => {
console.log(error);
});
I used the GitHub Search APi, and my goal is to write a function whose purpose is to check for each repository how much unused packaged it has. How can this be done?