I don't so much want a solution to what I am doing wrong as much as I want an explanation of what I am doing so far. This is mostly the starter-code given to me by an instructor. The purpose was to get my repositories from GitHub and display them on the page. I don't completely understand the code. Any help would be appreciated. Thank you. Any help on why my array repos.all is empty would be welcome too.
(function(module) {
const repos = {};
function MyRepos(rawDataObj) {
Object.keys(rawDataObj).forEach(key =>[key] = rawDataObj[key]);
}
console.log(rawDataObj);
repos.all = [];
console.log(repos.all);
repos.requestRepos = function(callback){
$.get(`https://api.github.com/users/userName/repos?access_token=${token}`)
.then(
reults => {
console.log(results);
repos.all = reults.map(ele => new MyRepos(ele));
callback();
});
};
repos.with = attr => repos.all.filter(repo => repo[attr]);
module.repos = repos;
})(window);