This is my Stage 0 task for the HNG Internship (HNG13).
The goal was simple: build a RESTful API endpoint that returns my basic profile information along with a random cat fact fetched from an external API.
π GitHub Repo: amiabl-programr/hng13-stage0-dynamic-profile-endpoint-project
π Live Demo: View on Railway
π οΈ Work Process
I built the app using Express.js, a fast and minimalist Node.js framework.
Steps:
- Created a /me endpoint that returns:
- My name, email, and GitHub username
- A random cat fact fetched via the Cat Facts API
- Used Axios for external API requests
- Implemented error handling for network issues and invalid routes
- Structured the JSON response neatly for easy readability
app.get("/me", async (req, res) => {
try {
const { data } = await axios.get("https://catfact.ninja/fact");
res.json({
name: "Victor Oluwayemi",
github_username: "amiabl-programr",
email: "your_email@example.com",
cat_fact: data.fact,
});
} catch (error) {
res.status(500).json({ error: "Unable to fetch cat fact" });
}
});
Handling Unknown Routes
The latest Express version no longer supports using a plain "*" wildcard.
Instead, I handled unknown routes like this:
app.use((req, res) => {
res.status(404).json({ error: "Route not found" });
});
βοΈ Hosting Experience
This part was... interesting π
- Tried Pxxl App β kept getting βNo service foundβ
- Tried Azure (Student Account) β ran into hostname/DNS errors
- Finally deployed on Railway, and it worked like magic π
π‘ What This Task Taught Me
Even though the task seemed simple, I learned quite a few things:
- How to use Axios effectively and handle errors gracefully
- How route handling changed in newer versions of Express
- The importance of understanding different deployment platforms
- And of course, patience β because deployment βwahalaβ is real π
β¨ Final Thoughts
What started as a simple task turned into a mini learning journey β from backend structure to debugging, and finally deployment.
This project helped me:
- Improve my understanding of Express.js
- Get comfortable with error handling
- Gain hands-on experience deploying Node.js apps to the cloud
- Iβm looking forward to the next stage of the HNG journey π
Built with β€οΈ by Victor Oluwayemi
Top comments (0)