Kamlesh Rajesh Yadav• 5,060
@Kamlesh0007
Posted
Congratulations on completing the challenge! That's a great achievement, and I'm sure you put a lot of effort into it. I really liked the way you approached the challenge and the code you wrote. You demonstrated a good understanding of the concepts and applied them effectively to solve the problem.I have a few suggestions to improve your code further. You need to add a loader while fetching data from an API, you can follow these steps: add this code in ur javascript with css of loader in ur stylesheet
const loader = document.getElementById('loader');
function showLoader() {
loader.style.display = 'block';
}
function hideLoader() {
loader.style.display = 'none';
}
// Example of fetching data from an API
const advice = async () => {
showLoader();
try {
const response = await fetch('https://api.adviceslip.com/advice');
const data = await response.json()
hideLoader();
return data
} catch (error) {
console.log(error);
}
}
Marked as helpful
1