Endpoint: GET /users/getrandomuser
Description: Retrieve a random user from the database. This endpoint does not require authentication and can be used to get sample user data.
Request Body:
No request body required.
Success Response (200):
{
"success": true,
"data": {
"_id": "507f1f77bcf86cd799439011",
"username": "randomuser123",
"name": "Jane Smith",
"email": "jane.smith@example.com",
"avatar": "https://example.com/avatars/jane.jpg",
"createdAt": "2023-06-15T08:30:00.000Z",
"updatedAt": "2023-06-15T08:30:00.000Z"
}
}
Error Responses:
404 Not Found:
{
"success": false,
"message": "No users found in the database"
}
500 Internal Server Error:
{
"success": false,
"message": "Internal server error occurred while fetching random user"
}
Notes:
-
This endpoint is public and does not require authentication
-
Returns a randomly selected user from the database
-
Useful for testing, demos, or populating sample data
-
The response structure matches the standard user object format