<?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: Ann Ngatia</title>
    <description>The latest articles on DEV Community by Ann Ngatia (@ann_ngatia_7).</description>
    <link>https://dev.to/ann_ngatia_7</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%2F3290100%2F3a90c761-9559-4b0f-827b-d5b3934dca7b.png</url>
      <title>DEV Community: Ann Ngatia</title>
      <link>https://dev.to/ann_ngatia_7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ann_ngatia_7"/>
    <language>en</language>
    <item>
      <title>How I Built My First Recipe Explorer App Using JSON Server and JavaScript</title>
      <dc:creator>Ann Ngatia</dc:creator>
      <pubDate>Tue, 24 Jun 2025 08:32:04 +0000</pubDate>
      <link>https://dev.to/ann_ngatia_7/how-i-built-my-first-recipe-explorer-app-using-json-server-and-javascript-5b1f</link>
      <guid>https://dev.to/ann_ngatia_7/how-i-built-my-first-recipe-explorer-app-using-json-server-and-javascript-5b1f</guid>
      <description>&lt;p&gt;As a beginner in web development, I recently completed a fun and educational project — a Recipe Explorer App. This project helped me practice HTML, CSS, JavaScript, and learn how to use JSON Server to handle data like a real API. In this blog post, I’ll walk through how I built it and what I learned in the process.&lt;/p&gt;

&lt;p&gt;🧱 Project Overview&lt;br&gt;
The main features of my Recipe Explorer App are:&lt;/p&gt;

&lt;p&gt;Viewing a list of recipes with their ingredients and instructions.&lt;/p&gt;

&lt;p&gt;Adding new recipes through a form.&lt;/p&gt;

&lt;p&gt;All recipe data is stored and managed using JSON Server, which simulates a RESTful API and makes front-end development feel like it’s connected to a real back end.&lt;/p&gt;

&lt;p&gt;🧩 Tools and Technologies Used&lt;br&gt;
HTML/CSS – for structure and styling.&lt;/p&gt;

&lt;p&gt;JavaScript – to handle logic and DOM manipulation.&lt;/p&gt;

&lt;p&gt;JSON Server – to simulate a database and API.&lt;/p&gt;

&lt;p&gt;VS Code – my development environment.&lt;/p&gt;

&lt;p&gt;Git &amp;amp; GitHub – for version control and backup.&lt;/p&gt;

&lt;p&gt;🔄 Displaying Recipes&lt;br&gt;
I used the fetch() method to retrieve data from the JSON Server, and then displayed each recipe using dynamic DOM manipulation.&lt;/p&gt;

&lt;p&gt;Here’s a basic example of the code:&lt;/p&gt;

&lt;p&gt;javascript&lt;br&gt;
Copy&lt;br&gt;
Edit&lt;br&gt;
fetch('&lt;a href="http://localhost:3000/recipes'" rel="noopener noreferrer"&gt;http://localhost:3000/recipes'&lt;/a&gt;)&lt;br&gt;
  .then(response =&amp;gt; response.json())&lt;br&gt;
  .then(data =&amp;gt; {&lt;br&gt;
    data.forEach(recipe =&amp;gt; renderRecipe(recipe));&lt;br&gt;
  });&lt;/p&gt;

&lt;p&gt;function renderRecipe(recipe) {&lt;br&gt;
  const recipeCard = document.createElement('div');&lt;br&gt;
  recipeCard.innerHTML = &lt;code&gt;&lt;br&gt;
    &amp;lt;h3&amp;gt;${recipe.name}&amp;lt;/h3&amp;gt;&lt;br&gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Ingredients:&amp;lt;/strong&amp;gt; ${recipe.ingredients}&amp;lt;/p&amp;gt;&lt;br&gt;
    &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Instructions:&amp;lt;/strong&amp;gt; ${recipe.instructions}&amp;lt;/p&amp;gt;&lt;br&gt;
&lt;/code&gt;;&lt;br&gt;
  document.querySelector('#recipe-list').appendChild(recipeCard);&lt;br&gt;
}&lt;br&gt;
This code gets the data from the server and calls a function to display each recipe on the page.&lt;/p&gt;

&lt;p&gt;➕ Adding New Recipes&lt;br&gt;
I created a form to allow users to add new recipes. When the form is submitted, it sends a POST request to JSON Server, which adds the recipe to the database and updates the UI.&lt;/p&gt;

&lt;p&gt;Here’s how the add feature works:&lt;/p&gt;

&lt;p&gt;javascript&lt;br&gt;
Copy&lt;br&gt;
Edit&lt;br&gt;
form.addEventListener('submit', (e) =&amp;gt; {&lt;br&gt;
  e.preventDefault();&lt;br&gt;
  const newRecipe = {&lt;br&gt;
    name: nameInput.value,&lt;br&gt;
    ingredients: ingredientsInput.value,&lt;br&gt;
    instructions: instructionsInput.value&lt;br&gt;
  };&lt;/p&gt;

&lt;p&gt;fetch('&lt;a href="http://localhost:3000/recipes" rel="noopener noreferrer"&gt;http://localhost:3000/recipes&lt;/a&gt;', {&lt;br&gt;
    method: 'POST',&lt;br&gt;
    headers: {'Content-Type': 'application/json'},&lt;br&gt;
    body: JSON.stringify(newRecipe)&lt;br&gt;
  })&lt;br&gt;
  .then(response =&amp;gt; response.json())&lt;br&gt;
  .then(data =&amp;gt; renderRecipe(data));&lt;br&gt;
});&lt;br&gt;
This allowed me to practice sending data to a server and updating the page without refreshing.&lt;/p&gt;

&lt;p&gt;🤯 Lessons Learned&lt;br&gt;
I became more confident using fetch() for GET and POST requests.&lt;/p&gt;

&lt;p&gt;JSON Server is a great tool for simulating real APIs during development.&lt;/p&gt;

&lt;p&gt;Building this app helped me understand the importance of separating logic into functions.&lt;/p&gt;

&lt;p&gt;Small projects like this are perfect for learning how front-end and back-end parts connect.&lt;/p&gt;

&lt;p&gt;📌 Final Thoughts&lt;br&gt;
Creating this Recipe Explorer App helped me put everything I’ve been learning into practice. It showed me how front-end apps can interact with data, and gave me a taste of how full web apps are built.&lt;/p&gt;

&lt;p&gt;In the future, I’d love to expand this project by adding edit functionality or search filters — but for now, I’m proud of what I’ve built.&lt;/p&gt;

&lt;p&gt;If you’re a beginner like me, I highly recommend starting with a small project like this. You’ll learn a lot and have fun doing it!&lt;/p&gt;

&lt;p&gt;🧠 Pro Tip&lt;br&gt;
To start JSON Server and make it serve your data, use this command in your terminal:&lt;/p&gt;

&lt;p&gt;bash&lt;br&gt;
Copy&lt;br&gt;
Edit&lt;br&gt;
json-server --watch db.json&lt;br&gt;
Make sure your db.json file contains your initial recipe data.&lt;/p&gt;

&lt;p&gt;📚 References&lt;br&gt;
MDN Web Docs: fetch()&lt;/p&gt;

&lt;p&gt;JSON Server GitHub&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
