Have problem with adding a inside innerHTML in a .catch(error)
Inside the .catch(), remove the console.error() and set the innerHTML of the authorContainer to a p element with a class attribute of "error-msg" and text "There was an error loading the authors". const authorContainer = document.getElementById('author-container'); fetch('https://cdn.freecodecamp.org/curriculum/news-author-page/authors.json') .then((res) => res.json()) .then((data) => { authorDataArr = data; displayAuthors(authorDataArr.slice(startingIndex, endingIndex)); }) .catch((err) => { authorContainer.innerHTML += ` <p class="error-msg">There was an error loading the authors</p>`; });
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.