Assignemnt-4(Async, AXIOS)
Assignemnt-4(Async, AXIOS)
Assignment 4
Asynchronous JS, AXIOS, JSON Server, HTTP Methods, and Status Codes
1. Create a function checkAge that takes a person's age as an argument and checks if
they are eligible to vote. If the age is 18 or above, resolve the promise after 2 seconds;
if below 18, reject the promise. Use async/await and try/catch to call the function and
display a message indicating whether the person is eligible to vote.
2. Write an asynchronous function that will generate a random integer number between
1 and 100 after 3 seconds. Write another function that will check whether the number
is prime or not by using a promise. If the number is prime the promise will resolve
and reject otherwise. Use async/await and try/catch to call both the functions and
display the generated number and also display if it is even or odd.
3. Fetch products from https://fakestoreapi.com/products using axios. In the HTML page
display the product image, name and price in product card format. Use async/await
for asynchronous data fetching and try/catch to handle possible errors.
4. Create a JSON server with 3 student records. Each student has an id, name, branch,
and CGPA. Run the server and perform the following operations using vanilla JS, and
AXIOS. Use async/await and try/catch whenever required.
a. Create an HTML form to add a new student to the JSON server file.
b. Display all the available student records in an HTML file in a tabular format
c. Create two buttons Update and Delete with each row to perform an update
and delete operation.
d. On the update page populate the form with the existing data (name, branch,
and CGPA) and update the student with newly given details.
e. Create a search field to search students based on their names.
f. Create easy navigation between these pages and style the pages with CSS.