Skip to content
Snippets Groups Projects

Partially Completed Assignment 3.2

Merged Shreya Sharma requested to merge assignment-3.2 into master
16 files
+ 195
96
Compare changes
  • Side-by-side
  • Inline
Files
16
+ 24
13
const axios = require('axios');
const base_api_url = 'https://api.github.com';
const accessToken = 'access_token=71f1e4e711a6a25922369ff3f847485c8866fd24&scope=notifications%2Cpublic_repo%2Cuser&token_type=bearer';
const username = 'shreyasharmaxo'
// Collect and parse user's profile information
exports.getProfileInfo =
function(username) {
function() {
return axios.get(base_api_url + '/users/' + username)
.then(function(res) {
return parseProfileInfo(res.data);
@@ -22,7 +23,8 @@ function parseProfileInfo(info) {
'email': 'shreya.sharma4697@gmail.com',
'repositories': info.public_repos,
'followers': info.followers,
'following': info.following
'following': info.following,
'avatar': info.avatar_url
}
return parsedProfile;
@@ -30,7 +32,7 @@ function parseProfileInfo(info) {
// Collect and parse user's repository information
exports.getRepoInfo =
function(username) {
function() {
return axios.get(base_api_url + '/users/' + username + '/repos')
.then(function(res) {
return parseRepoInfo(res.data);
@@ -45,19 +47,28 @@ function parseRepoInfo(info) {
for (r of info) {
parsedRepositories.push({
'name': r.name,
'owner': r.owner.login,
'description': r.description,
'url': r.html_url
'name': r.name,
'owner': r.owner.login,
'description': r.description,
'url': r.html_url
});
}
return parsedRepositories;
}
// Collect and parse user's notification information
exports.getNotificationInfo =
function () {
return axios.get(base_api_url + '/notifications?' + accessToken)
.then(function(res) {
return res.data;
})
}
// Collect and parse user's follower/following information
exports.getFollowersInfo =
function(username) {
function() {
return axios.get(base_api_url + '/users/' + username + '/followers')
.then(function(res) {
return parseFollowInfo(res.data);
@@ -68,7 +79,7 @@ function(username) {
}
exports.getFollowingInfo =
function(username) {
function() {
return axios.get(base_api_url + '/users/' + username + '/following')
.then(function(res) {
return parseFollowInfo(res.data);
@@ -84,9 +95,9 @@ function parseFollowInfo(info) {
for (f of info) {
parsedFollows.push(
{
'username': f.login,
'avatar': f.avatar_url,
'url': f.html_url
'username': f.login,
'avatar': f.avatar_url,
'url': f.html_url
});
}
Loading