From f6c8b39d6cca61ca9ac0dc650e48a102018fc539 Mon Sep 17 00:00:00 2001 From: mani pandit Date: Sun, 22 Oct 2023 11:07:46 +0530 Subject: [PATCH] fixed catch block with console statements --- contributers.js | 72 +++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/contributers.js b/contributers.js index 01c3dea..1feeb60 100644 --- a/contributers.js +++ b/contributers.js @@ -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) => + `
${user.login} @@ -51,12 +54,11 @@ document.addEventListener('DOMContentLoaded', () => { Profile
` - ) - maintainersContainer.innerHTML = userHTML.join(""); - }) - .catch(error => { - console.error("Everything is wrong mann...") - }) + ); + maintainersContainer.innerHTML = userHTML.join(""); + }); }) -}) - + .catch((error) => { + console.error("Everything is wrong mann..."); + }); +});