diff --git a/public/js/profileGen.js b/public/js/profileGen.js
index 00fe32e..2098361 100644
--- a/public/js/profileGen.js
+++ b/public/js/profileGen.js
@@ -1,44 +1,65 @@
function profileGen(username, container) {
queryAPIByUser("", username, (user) => {
- console.log(user);
- html =
- "
\
-
\
-
"+user.name+"
\
-
"+user.login+"
\
-
Followers: "+user.followers+"
\
-
Following: "+user.following+"
\
-
\
-
"+(user.bio != null ? "Bio: "+user.bio : "")+"
\
-
"+(user.location != null ? "Location: "+user.location : "")+"
\
-
"+(user.email != null ? "Email: "+user.email : "")+"
\
-
"+(user.blog != null ? "Site: "+user.blog : "")+"
\
-
"+(user.company != null ? "Company: "+user.company : "")+"
\
-
"+(user.organizations_url != null ? "Organizations: "+parseOrgs(user.organizations_url) : "")+"
\
-
"+user.html_url+" \
- \
- "
- $("#"+container).html(html);
+ parseOrgs(user.login).then(function(orgsReturn) {
+ let html =
+ " \
+
\
+
"+user.name+"
\
+
"+user.login+"
\
+
Followers: "+user.followers+"
\
+
Following: "+user.following+"
\
+
"+(user.bio != null ? "Bio: "+user.bio : "")+"
\
+
"+(user.location != null ? "Location: "+user.location : "")+"
\
+
"+(user.email != null ? "Email: "+user.email : "")+"
\
+
"+(user.blog != null ? "Site: "+user.blog : "")+"
\
+
"+(user.company != null ? "Company: "+user.company : "")+"
\
+
"+(user.organizations_url != null ? "Organizations: "+orgsReturn: "")+"
\
+
"+user.html_url+" \
+ \
+ "
+ $("#"+container).html(html);
+ })
}, () => {
console.error("error getting user info");
});
}
-function parseOrgs(oranization_url) {
- queryOrgUrl(oranization_url, (orgs) => {
- for (org in orgs) {
- console.log(org);
- }
+async function parseOrgs(name) {
+ const urlpath = `api/users/${name}/orgs`;
+ let orgs_final = [];
+
+ await queryUrl(urlpath, async (orgs) => {
+ orgs.map(org => {
+ return new Promise(function (res, rej) {
+ url = org.url;
+ queryUrl(url, (orgData) => {
+ orgs_final.push("");
+ //console.log(orgs_final);
+ res();
+ }, () => {
+ console.error("error getting org info");
+ });
+ });
+ });
+ console.log(orgs);
+ await Promise.all(orgs);
}, () => {
console.error("error getting orgs");
- })
+ });
+
+ console.log(orgs_final);
+ console.log(orgs_final.length);
+ console.log(orgs_final[0]);
+ return orgs_final.join(" ");
}
-function queryOrgUrl(url, successCallBack, errorCallBack) {
- console.log(urlpath);
+
+
+function queryUrl(url, successCallBack, errorCallBack) {
+ console.log(url);
$.ajax({
type:'GET',
- url: urlpath,
+ url: url,
crossDomain: true,
dataType: "json",
success: successCallBack,