3 comments
Here's the fix for the async issue:
1async function fetchUser(id: string) {2 const response = await fetch(`/api/users/${id}`)3 if (!response.ok) {4 throw new Error('Failed to fetch user')5 }6 return response.json()7}Perfect! That resolves the race condition.
Here's the Python equivalent for reference:
1async def fetch_user(user_id: str):2 response = await client.get(f"/api/users/{user_id}")3 response.raise_for_status()4 return response.json()