What I Built
As part of a backend project challenge, I created a RESTful API endpoint /me that returns:
- My profile details
- A dynamic cat fact
- The current UTC timestamp
It uses Node.js and Express, and fetches data from the Cat Facts API
Tech Stack
- Node.js
- Express.js
- Axios
- dotenv
- Railway (for deployment)
API Endpoint
GET /me
Example response:
{
"status": "success",
"user": {
"email": "kumarrishi9862@gmail.com",
"name": "Kumar Rishi",
"stack": "Node.js/Express"
},
"timestamp": "2025-10-18T12:34:56.789Z",
"fact": "Cats have over 20 muscles that control their ears."
}
Live Demo
Visit the live endpoint here:
Endpoint:
Expected Response:
How It Works
- /me endpoint returns a new response on each request
- Fetches a fresh cat fact using Axios from the external API
- Adds the current UTC time using new Date().toISOString()
- Handles failure of the Cat Facts API gracefully
Error Handling
If the Cat Fact API fails or times out, the endpoint returns a fallback message instead of crashing.
Challenges & Highlights
- Managing external API timeouts and errors taught me the importance of graceful degradation in real-world apps.
- Handling environment variables securely using dotenv helped me keep sensitive data cleanly separated.
- Deploying to Railway was smooth and a great way to quickly get a backend app live and accessible for testing.
- Structuring the JSON response to exactly match the required schema pushed me to pay extra attention to detail.
What I Learned
- How to integrate 3rd-party APIs with Axios
- Managing environment variables securely
- Structuring clean JSON responses
- Deploying apps on Railway
GitHub Repo
Here’s the code if you’d like to see how it works:
👉 Github Repo
🙌 Thanks!
Let me know what you think! Feel free to clone it, test it, or build on top.
Top comments (0)