Skip to content

Commit

Permalink
added response json
Browse files Browse the repository at this point in the history
  • Loading branch information
isuru117 committed Oct 17, 2019
1 parent bb7d4af commit 0d6b332
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions back-end/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require('dotenv').config();
const port = process.env.PORT;
const octokit = new Octokit({ auth: process.env.SECRET });

var dataSet={};
var dataSet = {};

app.get('/', async (req, res) => {

Expand All @@ -16,30 +16,36 @@ app.get('/', async (req, res) => {
type: "public"
});

repoData.data.forEach(async repo => {
let fetchedContributors = [];


const x = await Promise.all(repoData.data.map(async repo => {
const repoName = repo.name;

const result = await octokit.repos.getContributorsStats({
owner: "99xt-incubator",
repo: repoName
});

let fetchedContributors = [repoName];

result.data.map(contributor => {
if (fetchedContributors.length != 0) {
fetchedContributors.map(ftCon => {
if (ftCon != contributor.author.login) {
fetchedContributors.push(contributor.author.login);
}
});
}
// if (fetchedContributors.length != 0) {
// fetchedContributors.map(ftCon => {
// if (ftCon != contributor.author.login) {
fetchedContributors.push(contributor);
});
// });
// }
// });


dataSet[repoName]=fetchedContributors;
dataSet[repoName] = fetchedContributors;

})).then(() => {
res.json(dataSet);
}).catch(err => {
console.log(err);
});
res.send("<h1>" + dataSet + "</h1>");


});

Expand Down

0 comments on commit 0d6b332

Please sign in to comment.