/News-Article-From-TechCrunch

This is a pseudo Frontend application in which lists and displays the most recent published posts. News Articles API: https://techcrunch.com/wp-json/wp/v2/posts?per_page=20&context=embed

Primary LanguageJavaScript

This is a pseudo Frontend application in which lists and displays the most recent published posts.

News Articles API: https://techcrunch.com/wp-json/wp/v2/posts?per_page=20&context=embed

<<<<<<< HEAD

This code includes several functions that work together to fetch and display a list of posts from the TechCrunch API.

First, there is the fetchPosts function, which makes an asynchronous call to the TechCrunch API and returns the response as JSON. If an error occurs during the fetch, the function will return null.

The createPostCard function takes a single post object and creates an HTML element that displays the post's title, excerpt, and image. The function also sets the href attribute of the post's title to the post's link, and adds an event listener to the post element that adds a "hover" class when the user hovers over the element.

The renderPostList function is the main function that fetches and displays the list of posts. It first creates a loader element, which is displayed while the posts are being fetched. Then, it calls the fetchPosts function and waits for the response. If the response is null, the function displays an error message. Otherwise, it clears the current content of the post list (if any) and creates and adds a post element for each post in the response. Finally, the function removes the loader element.

Overall, this code allows users to display a list of posts from the TechCrunch API on their webpage, with a loader displayed while the posts are being fetched. If an error occurs during the fetch, the code displays an error message instead of the post list.

======= >>>>>>> fd988d6e6c95ba05075ed278c506af061e8334e9