Compose Parallel Bookstore Requests and Match Authors
Quick Overview
Compose parallel bookstore API requests with Promise.all, join books to authors by user ID, and handle missing records, failures, and concurrency limits.
Compose Parallel Bookstore Requests and Match Authors
Company: Circle
Role: Frontend Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Onsite
A bookstore frontend supports CRUD operations and needs to fetch several resources in parallel, then show each record with its corresponding author's user data. Explain and implement the request-composition pattern using `Promise.all`, matching authors by user ID rather than by array position.
### Constraints & Assumptions
Concrete endpoint names and payload fields are supplied by the backend adapter. Use illustrative `getBooks`, `getUsers`, and stable `authorUserId`/`id` fields only to explain the pattern, not as claimed original API signatures.
### Clarifying Questions to Ask
- Can both datasets be fetched independently, or are author IDs known only after loading books?
- Should one failed request fail the entire view, or should partial data remain usable?
- What should appear when an author's user record is missing?
```hint Join by identity
Parallel requests can complete in any order, and returned arrays need not share the same ordering.
```
### What a Strong Answer Covers
- Launching independent promises before awaiting them.
- Building an ID index and handling missing author records explicitly.
- Choosing all-or-nothing versus partial failure behavior.
### Follow-up Questions
- How would you avoid one duplicate user request per book?
- When is unbounded Promise.all concurrency inappropriate?
Overview: Compose parallel bookstore API requests with Promise.all, join books to authors by user ID, and handle missing records, failures, and concurrency limits.
A bookstore frontend supports CRUD operations and needs to fetch several resources in parallel, then show each record with its corresponding author's user data. Explain and implement the request-composition pattern using Promise.all, matching authors by user ID rather than by array position.
Constraints & Assumptions
Concrete endpoint names and payload fields are supplied by the backend adapter. Use illustrative getBooks, getUsers, and stable authorUserId/id fields only to explain the pattern, not as claimed original API signatures.
Clarifying Questions to Ask Guidance
Can both datasets be fetched independently, or are author IDs known only after loading books?
Should one failed request fail the entire view, or should partial data remain usable?
What should appear when an author's user record is missing?
What a Strong Answer Covers Guidance
Launching independent promises before awaiting them.
Building an ID index and handling missing author records explicitly.
Choosing all-or-nothing versus partial failure behavior.
Follow-up Questions Guidance
How would you avoid one duplicate user request per book?
When is unbounded Promise.all concurrency inappropriate?