Overview
The Rodando Passenger app uses Angular’sHttpClient to communicate with the backend REST API. All HTTP services follow consistent patterns for error handling, response unwrapping, and authentication.
Service Architecture
Base Patterns
All HTTP services in the app follow these patterns:- Injectable Services: All services use
providedIn: 'root'for singleton instances - Environment Configuration: Base URLs come from
environment.apiUrl - Observable Returns: All methods return RxJS Observables
- Error Normalization: Errors are normalized to
ApiErrorinterface - Response Unwrapping: Backend responses are unwrapped from the
ApiResponse<T>wrapper
Service Structure
Environment Configuration
HTTP services use environment variables for base URLs:src/environments/environment.ts
Response Format
Standard API Response
All backend endpoints return a standardized wrapper:Response Unwrapping
Services automatically unwrap thedata field:
Error Handling
ApiError Interface
All errors are normalized to this interface:Error Normalization
TheAuthService implements comprehensive error normalization:
- Network errors:
status: 0, CORS issues, connection failures - HTTP errors: 4xx, 5xx status codes with parsed response bodies
- Validation errors: 422 responses with field-level errors
- Server errors: HTML responses, malformed JSON
- Progress events: Failed requests that emit ProgressEvent
Error Handling Example
Authentication
Web Sessions (Cookie-based)
For web flows, includewithCredentials: true to send HttpOnly cookies:
Mobile Sessions (Token-based)
For mobile flows, the access token is included via HTTP Interceptor:Available HTTP Services
Authentication & User
AuthService
Login, logout, token refresh, user profile
PassengerLocationApiService
Location pings and user profile with location (src/app/core/services/http/passenger-location-api.service.ts)
Mapbox Integration
MapboxDirectionsService
Route calculations and turn-by-turn directions
MapboxPlacesService
Geocoding, reverse geocoding, place search