Problem:
The PartsPilot frontend successfully received data from the backend, but the interface
failed when it attempted to run parts.map(). React expected
parts to be an array, but the state contained the complete response object.
Cause:
The FastAPI endpoint returned an object containing an items property rather
than returning an array directly. The frontend used setParts(data), which
stored the wrapper object in state. Array methods such as map could not be
used on that object.
Fix:
Inspected the returned JSON structure and changed the state update to
setParts(data.items). Confirmed the data path by working through the
response as object, property, array index, and item property before rendering it in JSX.
Lesson:
A successful API request does not guarantee that the returned data has the shape a
component expects. Before updating React state, inspect the response structure and store
the specific value the interface needs.