In this project, we will build a web-based E-commerce application that helps users to register, sign in, and view information of available cuisines, categories, and restaurants. The application should have the following features:
- Cuisines, Categories, and Restaurants Data Fetch: You have to write an advanced JavaScript code for the fetchData() function.
- This is a common function to fetch data from an API.
- This function is called by the loadContent() function to load cuisines, categories, and restaurants data.
- The loadContent() function is called on the onload event of the index.html page. This function is already implemented.
- The fetchData() function is called thrice by the loadContent() function to fetch cuisine data, category data, and restaurants data respectively.
- The above-mentioned URL endpoints are already mentioned in the loadContent() function.
- The fetchData() function takes two arguments: URL endpoints and the respective list elements from the index.html page.
- The function is declared as async as it's fetching data asynchronously.
- It also handles errors in case the data could not be fetched.