Exercise 1: Fetch Data from an API
- Write JavaScript code to fetch data from a public API (e.g., JSONPlaceholder or OpenWeatherMap) and log the response to the console.
Exercise 2: Handle Errors
- Modify the code from Exercise 1 to handle errors gracefully using
.catch()
and display an error message if the API request fails.
Exercise 3: Chaining Promises
- Fetch data from two different endpoints using Promises and log the combined result to the console.
Exercise 4: Promise.all
- Create an array of API requests and use
Promise.all
to fetch data from multiple endpoints simultaneously. Log the results to the console when all requests are complete.
Exercise 5: Async/Await
- Rewrite one of the previous exercises using the
async/await
syntax to fetch and display data.
Exercise 6: Error Handling with Async/Await
- Modify the code from Exercise 5 to handle errors using
try/catch
and display an error message if any API request fails.
Exercise 7: Fetch and Render
- Create a simple HTML page with a button. When the button is clicked, fetch data from an API and render it on the page.
Exercise 8: Loading Indicator
- Enhance the code from Exercise 7 by displaying a loading indicator (e.g., a spinner) while the data is being fetched and hiding it once the data is loaded.
Exercise 9: Pagination
- Implement pagination for a list of items fetched from an API. Allow users to click "Next" and "Previous" buttons to load more data.
Exercise 10: Data Post Processing
- Fetch data from an API and manipulate it in some way (e.g., filter, sort, or transform). Display the processed data on the webpage.