Endpoint
GET /api/favorites/check/:routeId
Authentication
This endpoint requires authentication. Include a valid Bearer token in the Authorization header.
Path Parameters
The unique identifier (UUID) of the route to check
Response
Indicates if the request was successful
Check result object
Whether the route is in user’s favorites
Favorite UUID (only present if isFavorite is true)
Example Request
curl https://api.example.com/api/favorites/check/987e6543-e21b-12d3-a456-426614174000 \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
Example Response
{
"success": true,
"data": {
"isFavorite": true,
"favoriteId": "fav_abc123"
}
}
Use Cases
- Display a “favorited” UI state (heart icon, bookmark, etc.)
- Toggle favorite status in the frontend
- Filter lists to show only non-favorited routes
Example Usage
// Check if route is favorited
const response = await fetch(
`https://api.example.com/api/favorites/check/${routeId}`,
{
headers: {
'Authorization': `Bearer ${token}`
}
}
);
const { data } = await response.json();
if (data.isFavorite) {
// Show filled heart icon
// Can use data.favoriteId to remove it later
} else {
// Show outline heart icon
}
Add Favorite
Add a route to favorites
Remove Favorite
Remove a route from favorites