AMS communicates with a remote backend through a thin, three-layer API stack: a shared Axios instance provides the base URL and default configuration; service modules wrap individual REST calls into named async functions; and Redux Thunks call those service functions and translate results (or errors) into store updates. This separation means switching from the current MockAPI backend to a production server requires changes in exactly one file.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Jay-byte389/AMS/llms.txt
Use this file to discover all available pages before exploring further.
Axios Instance
A single Axios instance is created insrc/services/api.js and imported by every service module. Centralising the instance means the base URL and any future default configuration are managed in one place.
No authentication headers are attached to any request. The MockAPI endpoint is publicly accessible, so no
Authorization header is required. See the production migration tip below for how to add auth headers.Doctor Service
fetchDoctorsAPI()
Fetches the complete list of doctors. Called by the
fetchDoctors thunk on the HomeScreen mount.fetchDoctorByIdAPI(id)
Fetches a single doctor by ID. Available for detail lookups when only an ID is known.
Appointment Service
| Function | Method | Endpoint | Used by thunk |
|---|---|---|---|
fetchAppointmentsFromApi() | GET | /Appointments | fetchAppointments |
createAppointmentOnApi(data) | POST | /Appointments | addAppointment |
updateAppointmentOnApi(appt) | PUT | /Appointments/:id | cancelAppointment |
How Thunks Call Services
Redux thunks are the only callers of service functions. They handle thetry/catch boundary and forward errors to Redux via rejectWithValue.
Error Handling Pattern
Every thunk follows the same error handling convention:Try the service call
The thunk
awaits the service function. If it resolves, the data is returned and becomes action.payload in the fulfilled reducer.Prefer structured API error
error.response?.data is checked first — this is the body of a non-2xx HTTP response, which may contain a structured error message from the backend.Fall back to error.message
If there is no response body (e.g. a network timeout), the JavaScript
Error.message string is used instead.