Countries List
This endpoint provides a list of available countries in the LAX application. The list is cached for 7 days to improve performance.
Request
Endpoint
- Method: GET
- URL:
/api/lists/countries
Request Headers
| Header | Value | Required |
|---|---|---|
| Content-Type | application/json | Yes |
| Accept | application/json | Yes |
| Accept-Language | en/ar | No |
Response Format
The response will include a list of countries with their IDs and names. The name will be returned in either English or Arabic based on the Accept-Language header.
Success Response
{
"success": true,
"message": "Data has been retrieved successfully",
"data": [
{
"id": 1,
"name": "Saudi Arabia"
},
{
"id": 2,
"name": "United Arab Emirates"
}
],
"status_code": 200
}
Error Responses
Invalid Accept Header (406)
{
"success": false,
"message": "Not Acceptable",
"data": null,
"status_code": 406
}
Invalid Content-Type (415)
{
"success": false,
"message": "Unsupported Media Type",
"data": null,
"status_code": 415
}
Server Error (500)
{
"success": false,
"message": "Something went wrong",
"data": null,
"status_code": 500
}
Cache Behavior
The countries list is cached for 7 days to improve performance. The cache is automatically invalidated when:
- A new country is added
- An existing country is updated
- A country is deleted
Response Fields
| Field | Type | Description |
|---|---|---|
| id | integer | Unique identifier for the country |
| name | string | Country name in the requested language (English/Arabic) |
Example Implementation Flow
- Make a GET request to
/api/lists/countries- Set Accept-Language header to get names in preferred language
- Upon success:
- Store the countries list in local state
- Use the list to populate country selection dropdowns
- Can be used in user registration or profile updates
- Note: The list is already sorted alphabetically by name
- Upon error:
- Display error message to user
- Implement retry mechanism if needed
- Check if the error is due to invalid headers and fix accordingly