Skip to content

Commit

Permalink
fixed catch block with console statements
Browse files Browse the repository at this point in the history
  • Loading branch information
manipandit committed Oct 22, 2023
1 parent c4846b6 commit f6c8b39
Showing 1 changed file with 37 additions and 35 deletions.
72 changes: 37 additions & 35 deletions contributers.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,51 @@
const container = document.querySelector('.contributors');
const maintainersContainer = document.querySelector('.maintainers');
const container = document.querySelector(".contributors");
const maintainersContainer = document.querySelector(".maintainers");

document.addEventListener('DOMContentLoaded', () => {
fetch('contributer.json')
.then(res => {
return res.json()
document.addEventListener("DOMContentLoaded", () => {
fetch("contributer.json")
.then((res) => {
return res.json();
})
.then((data) => {
console.log(data);
data.forEach(user => {
let contributorElement = document.createElement('div')
let avatar = document.createElement('img')
let userLink = document.createElement('a')
let userName = document.createElement('h3')
let userContributions = document.createElement('p')
// console.log(data);
data.forEach((user) => {
let contributorElement = document.createElement("div");
let avatar = document.createElement("img");
let userLink = document.createElement("a");
let userName = document.createElement("h3");
let userContributions = document.createElement("p");

// contributorElement
contributorElement.classList.add('contributor')
avatar.classList.add('avatar')

contributorElement.classList.add("contributor");
avatar.classList.add("avatar");

avatar.src = user.avatar_url;
avatar.alt = `${user.login}'s avatar`;
userName.textContent = user.login;
userLink.href = user.html_url;
userLink.target = '_blank';
userLink.textContent = 'Profile'
userLink.target = "_blank";
userLink.textContent = "Profile";
userContributions.textContent = `Contributions: ${user.contributions}`;

contributorElement.appendChild(avatar)
contributorElement.appendChild(userName)
contributorElement.appendChild(userContributions)
contributorElement.appendChild(userLink)
contributorElement.appendChild(avatar);
contributorElement.appendChild(userName);
contributorElement.appendChild(userContributions);
contributorElement.appendChild(userLink);

container.appendChild(contributorElement);

const filterUsers = data.filter(user => user.login === 'Prajwal0225' || user.login === 'madhurafulkar' )
const filterUsers = data.filter(
(user) =>
user.login === "Prajwal0225" || user.login === "madhurafulkar"
);

if(filterUsers.length === 0){
return "No maintainers in this project"
if (filterUsers.length === 0) {
return "No maintainers in this project";
}

const userHTML = filterUsers.map(user =>
`
const userHTML = filterUsers.map(
(user) =>
`
<div class="user">
<img src="${user.avatar_url}" class="avatar" alt="${user.login}"/>
Expand All @@ -51,12 +54,11 @@ document.addEventListener('DOMContentLoaded', () => {
<a href="${user.html_url}" target="_blank">Profile</a>
</div>
`
)
maintainersContainer.innerHTML = userHTML.join("");
})
.catch(error => {
console.error("Everything is wrong mann...")
})
);
maintainersContainer.innerHTML = userHTML.join("");
});
})
})

.catch((error) => {
console.error("Everything is wrong mann...");
});
});

0 comments on commit f6c8b39

Please sign in to comment.