As part of the HNG Internship Stage 0 backend task, I was asked to build a simple REST API that returns my profile information along with a dynamic cat fact from an external API.
Rather than using Express or any framework, I decided to go bare-metal โ using just Node.jsโ built-in http module.
This was a fun challenge that made me revisit the basics of how servers, routes, and responses actually work under the hood.
The goal was to create a GET endpoint at /me that returns a JSON response like this:
{
"status": "success",
"user": {
"email": "your@email.com",
"name": "Your Full Name",
"stack": "Node.js/Express"
},
"timestamp": "current UTC time in ISO 8601 format",
"fact": "random cat fact from Cat Facts API"
}
Dynamic data for the "fact" field comes from the Cat Facts API
๐ ๏ธ Technologies Used
Just the essentials:
๐ข Node.js
๐ป Built-in HTTP module
๐ Native Fetch API (available in Node 18+)
No Express, no frameworks, no extra dependencies, just JavaScript.
๐งฉ How It Works
1.The server listens for all incoming HTTP requests.
2.If the route matches /me, it:
- Fetches a random cat fact from https://catfact.ninja/fact
- Builds a structured JSON object containing my profile and the fact
- Sends it back with Content-Type: application/json
3.If anything goes wrong (like network errors), it falls back to a default cat fact.
4.Any other route returns a 404 Not Found.
๐งช Live Demo
๐ Live API:
https://hng13-be-stage-0-production.up.railway.app/me
๐งพ GitHub Repository:
https://github.com/tundealabi/hng13-be-stage-0
Top comments (0)