The preceding demo loaded a rehearsal schedule from offline functions. fetchUser, fetchPosts, and fetchNotifications here are local fixtures, not HTTP calls. Fetch the user first; its ID lets you request posts and notifications concurrently.
async function loadRoute() {
const parcel = await getParcel();
const [driver, depot] = await Promise.all([
getDriver(parcel.routeId), getDepot(parcel.routeId)
]);
return { driver, depot };
}
The parcel lookup provides the ID first. The other two calls begin together. Promise.all rejects if either request fails; wrap the calls in try/catch for your dashboard's fallback. All three fixture functions are supplied in script.js.
loadDashboard() and await fetchUser() before requesting data tied to its ID.Promise.all, passing the fetched ID to both.{ userName, postCount, unreadCount }, counting only unread notifications.{ userName: "Unknown", postCount: 0, unreadCount: 0 }.reportDashboard() to log Alex | posts: 3 | unread: 2 from the loaded dashboard. The starter calls it on startup.