This project demonstrates the use of JavaScript Promises, error handling, and simulated API calls using asynchronous functions. It mimics real-world data fetching scenarios like product catalogs, reviews, and sales reports with a success/failure mechanism.
To build a small application that leverages asynchronous API calls using Promises. You will also implement error handling to ensure that the application can manage unexpected issues gracefully
Your users should be able to:
- Apply Promises to manage multiple asynchronous operations in JavaScript.
- Implement chained Promises to handle sequential data retrieval and manage dependencies between API calls.
- Utilize .catch() and .finally() to handle errors and perform cleanup tasks in a Promise chain.
- Design custom error classes to improve error identification and debugging.
/project(mod-6/lab2) │ ├── index.html # Basic HTML page ├── main.js # Main script to run the promise chain ├── apiSimulator.js # Simulated API functions using Promises └── README.md
- Simulated asynchronous API calls
- Custom error classes for clearer error handling
- Promise chaining with
.then(),.catch(), and.finally() - Randomized success/failure logic to mimic real network behavior
Fetches a list of products. Has an 80% chance to succeed.
Takes a product ID and fetches reviews. Also has an 80% chance to succeed.
Returns a sales summary. Again, has an 80% success rate.
- Clone or download the project.
- Open
index.htmlin a browser with developer tools open (Console tab). - Reload the page to see simulated outputs — including possible failures.
- Check the Console for outputs and errors.
- Comments: README file is influenced by frontend mentor challenge projects README.