<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Fiona Nyadero</title>
    <description>The latest articles on DEV Community by Fiona Nyadero (@fiona_nyadero_0b288495ccc).</description>
    <link>https://dev.to/fiona_nyadero_0b288495ccc</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3573580%2F8dd1fe2b-0211-4cec-9f85-655fe64284e9.png</url>
      <title>DEV Community: Fiona Nyadero</title>
      <link>https://dev.to/fiona_nyadero_0b288495ccc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fiona_nyadero_0b288495ccc"/>
    <language>en</language>
    <item>
      <title>💻Building and Deploying My First Express API - HNG Stage 0 Task</title>
      <dc:creator>Fiona Nyadero</dc:creator>
      <pubDate>Sun, 19 Oct 2025 09:10:55 +0000</pubDate>
      <link>https://dev.to/fiona_nyadero_0b288495ccc/building-and-deploying-my-first-express-api-hng-stage-0-task-1h6e</link>
      <guid>https://dev.to/fiona_nyadero_0b288495ccc/building-and-deploying-my-first-express-api-hng-stage-0-task-1h6e</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;strong&gt;🚀 #HNG13 Stage 0 Task Completed!&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This week, I built and deployed a simple yet dynamic Express.js API as part of the HNG Internship.&lt;br&gt;
The challenge was to create an endpoint that returns:&lt;/p&gt;

&lt;p&gt;My personal details (from a predefined object),&lt;/p&gt;

&lt;p&gt;A timestamp, and&lt;/p&gt;

&lt;p&gt;A random cat fact fetched from a public API 🐱.&lt;/p&gt;

&lt;p&gt;Even though it sounds simple, the process was a great refresher on how real-world APIs are structured, tested, and deployed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧠 What I Did&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;1️⃣ Setting Up the Project&lt;/em&gt;&lt;br&gt;
I initialized a new Node.js project and installed the required dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init -y
npm install express axios dotenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;2️⃣ Writing the Server Code&lt;/em&gt;&lt;br&gt;
I used Express to handle HTTP requests and Axios to fetch data from an external API.&lt;br&gt;
Here’s what my route does:&lt;/p&gt;

&lt;p&gt;Sends my user details and the current timestamp.&lt;/p&gt;

&lt;p&gt;Fetches a cat fact from an API.&lt;/p&gt;

&lt;p&gt;If the API fails, it returns a fallback message:&lt;br&gt;
"Cats are mysterious, even when APIs fail."&lt;/p&gt;

&lt;p&gt;This taught me how to handle API errors gracefully — something developers face often.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;3️⃣ Environment Setup&lt;/em&gt;&lt;br&gt;
I created a .env file to store environment variables securely, like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PORT=3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and added .gitignore to ensure sensitive files aren’t pushed to GitHub:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node_modules
.env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;4️⃣ Deployment on Railway&lt;/em&gt;&lt;br&gt;
This was my favorite part!&lt;br&gt;
I pushed my project to GitHub and deployed it seamlessly on Railway:&lt;/p&gt;

&lt;p&gt;Connected my GitHub repo&lt;/p&gt;

&lt;p&gt;Set the environment variable PORT = 3000&lt;/p&gt;

&lt;p&gt;Clicked Deploy!&lt;/p&gt;

&lt;p&gt;Within seconds, my Express API was live at:&lt;br&gt;
🌐 &lt;a href="https://hng13-stage0-backend-production.up.railway.app" rel="noopener noreferrer"&gt;https://hng13-stage0-backend-production.up.railway.app&lt;/a&gt;&lt;br&gt;
😺 &lt;a href="https://hng13-stage0-backend-production.up.railway.app/me" rel="noopener noreferrer"&gt;https://hng13-stage0-backend-production.up.railway.app/me&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧩 What I Learned&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This task taught me:&lt;/p&gt;

&lt;p&gt;The importance of clean and readable API responses.&lt;/p&gt;

&lt;p&gt;How to use environment variables for secure configuration.&lt;/p&gt;

&lt;p&gt;How to deploy Express applications to production using Railway.&lt;/p&gt;

&lt;p&gt;How to log and handle errors gracefully without breaking the API.&lt;/p&gt;

&lt;p&gt;I also had to pay close attention to my file structure/naming and what is in my package.json&lt;/p&gt;

&lt;p&gt;It’s amazing how such a small task can sharpen so many essential backend skills!&lt;/p&gt;

</description>
      <category>restapi</category>
      <category>backend</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
