function profileGen(username, container) { queryAPIByUser("", username, (user) => { 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"); }); } 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 queryUrl(url, successCallBack, errorCallBack) { console.log(url); $.ajax({ type:'GET', url: url, crossDomain: true, dataType: "json", success: successCallBack, error:errorCallBack }); }