Asynchronous JS Assignment– 4

Basic Questions

  1. Write a fetch request to get posts from https://jsonplaceholder.typicode.com/posts and log only the titles.
  2. Use fetch to get comments from an API and filter comments with email ending in .org.
  3. Write a fetch request that retrieves users and maps them into an array of names only.
  4. Fetch todos from the API and log only those with completed: true.
  5. Write code to fetch photos and display the first 10 thumbnailUrl.
  6. Use fetch to get data and transform it into a key-value object using reduce.
  7. Write a fetch request that gets posts and counts how many posts each user has.
  8. Fetch data from API and log the total number of objects received.
  9. Fetch users and log the names sorted alphabetically.
  10. Fetch posts and log the title of the longest post.
  11. Fetch todos and calculate the percentage of completed tasks.
  12. Write a fetch request to retrieve albums and group them by userId.
  13. Fetch posts and log the top 3 longest titles.
  14. Fetch users and log only users who live in a specific city.
  15. Fetch comments and log all emails in uppercase.
  16. Fetch posts and count how many titles contain more than 5 words.
  17. Fetch todos and separate them into completed and pending arrays.
  18. Fetch users and print their name and company.name together.
  19. Fetch comments and log all unique email domains.
  20. Fetch albums and log album IDs where the title contains the word accusamus

Intermediate Questions

  1. Write a POST request with fetch to create a new user with {name, email} and log the created ID.
  2. Use fetch to PUT (update) the title of post id=1.
  3. Use fetch to DELETE a post with id=1 and log success/failure.
  4. Send form data using fetch and log the server response.
  5. Write code to make two fetch requests (posts + users) and combine them into a single array with {userName, postTitle}.
  6. Use fetch with Promise.all to get posts, users, and comments simultaneously.
  7. Write a fetch function that retries 3 times if the request fails.
  8. Fetch posts and paginate them (5 per page) using async-await.
  9. Fetch photos and save only URLs ending with .jpg.
  10. Write code to fetch posts and limit response to first 5 results using query params.
  11. Fetch comments and group them by postId.
  12. Fetch posts and display word frequency across all titles.
  13. Fetch data and handle timeout if it takes more than 3 seconds.
  14. Write code to fetch nested JSON and safely access user.address.city.
  15. Use fetch to download a text file and display the number of words in it.
  16. Write a fetch request that uploads a JSON file using FormData.
  17. Fetch users and log only those with geo.lat greater than 0.
  18. Fetch todos and create a map of userId → totalTasks.
  19. Fetch albums and log only unique album titles.
  20. Write code to fetch comments and replace every vowel in body with *.

Advanced Questions

  1. Implement a fetch wrapper that always logs request time and response size.
  2. Fetch paginated API data until no more pages are left, and merge all results.
  3. Write code to download a large file using fetch with ReadableStream and count chunks.
  4. Fetch posts and comments, merge them so each post contains its related comments.
  5. Implement a fetch request with exponential backoff retries (1s, 2s, 4s…).
  6. Use fetch with AbortController to cancel request if it takes more than 2 seconds.
  7. Write a fetch function that standardizes error responses into {status, message}.
  8. Fetch two APIs (users + todos) and log only completed tasks with user names.
  9. Implement a batch fetcher that makes 10 requests concurrently but processes them sequentially.
  10. Write a microservice simulation: one fetch gets user IDs, another fetch gets posts for those IDs, and combine them into one dataset.