<?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: Tabitha Ko3ch</title>
    <description>The latest articles on DEV Community by Tabitha Ko3ch (@tabithakoech).</description>
    <link>https://dev.to/tabithakoech</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%2F878066%2F69795148-d6aa-41c3-b30d-f0356535c95d.jpeg</url>
      <title>DEV Community: Tabitha Ko3ch</title>
      <link>https://dev.to/tabithakoech</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tabithakoech"/>
    <language>en</language>
    <item>
      <title>React-Cocktail-recipes</title>
      <dc:creator>Tabitha Ko3ch</dc:creator>
      <pubDate>Sun, 31 Jul 2022 10:41:42 +0000</pubDate>
      <link>https://dev.to/tabithakoech/react-cocktail-recipes-3p29</link>
      <guid>https://dev.to/tabithakoech/react-cocktail-recipes-3p29</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bGQep-kA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1vxz8m6plmhjj7j4sb5i.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bGQep-kA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1vxz8m6plmhjj7j4sb5i.jpg" alt="Cocktail" width="880" height="660"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This app is called Cocktail Bazaar. The app allows you to search for cocktails by inputting whatever ingredient you wish. The cocktails are then listed on the page which you can then hover on the cocktail image  to view the recipe details &lt;/p&gt;

&lt;p&gt;I fetched my cocktail data from “The Cocktail DB API”  The fetch request occurs when the user searches a cocktail on the search bar.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5GEC95bs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fc73w0mj9kbin366q15d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5GEC95bs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fc73w0mj9kbin366q15d.png" alt="Fetch api" width="880" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The data fetched from the API was the cocktail image,name,recipe,glass and category.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zK71i9cl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lejyd6trfnzb476bplse.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zK71i9cl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lejyd6trfnzb476bplse.png" alt="fetched data" width="880" height="505"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Using fetch() API on cocktailsDB API to display random cocktail inspirations with their recipes</title>
      <dc:creator>Tabitha Ko3ch</dc:creator>
      <pubDate>Sun, 26 Jun 2022 20:09:00 +0000</pubDate>
      <link>https://dev.to/tabithakoech/using-fetch-api-on-cocktailsdb-api-to-display-random-cocktail-inspirations-with-their-recipes-fe8</link>
      <guid>https://dev.to/tabithakoech/using-fetch-api-on-cocktailsdb-api-to-display-random-cocktail-inspirations-with-their-recipes-fe8</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
The fetch()api allows us to make HTTPS requests from the server to the browser.&lt;br&gt;
We create a simple application that generates random cocktail inspirations to the users using the&lt;a href="https://www.thecocktaildb.com/api/json/v1/1/random.php"&gt;CocktailsDB API&lt;/a&gt;&lt;br&gt;
Used Fetch API to get a list of cocktails from the Cocktails DB api Getting:&lt;br&gt;
Cocktail image, Cocktail name, Cocktail glass,cocktail ingredients and measures&lt;br&gt;
&lt;strong&gt;&lt;em&gt;JavaScript concepts used&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
 DOM manipulation&lt;br&gt;
 fetch() API&lt;br&gt;
 Event listeners&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pPd-mb39--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tkx8zd7qtel5r9prcfd3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pPd-mb39--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tkx8zd7qtel5r9prcfd3.png" alt="Screenshot" width="880" height="235"&gt;&lt;/a&gt;&lt;br&gt;
Create an empty folder where you will store the project.&lt;br&gt;
The folder should have an index.js file , an index.html file and a style.css for custom styling &lt;br&gt;
We start by making a fetch request to the CocktailsDB API URL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch('https://www.thecocktaildb.com/api/json/v1/1/random.php')
        .then(res =&amp;gt; res.json())
        .then(res =&amp;gt; {
        createCocktail(res.drinks[0]);
    });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After sending a fetch request to the API we get the list of the random cocktails, their images,ingredients, measure and recipe instructions and we update it on the DOM.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const createCocktail = (cocktail) =&amp;gt; {
    const ingredients = [];
    // Get all ingredients from the object. Up to 20
    for(let i=1; i&amp;lt;=20; i++) {
        if(cocktail[`strIngredient${i}`]) {
            ingredients.push(`${cocktail[`strIngredient${i}`]} - ${cocktail[`strMeasure${i}`]}`)
        } else {
            // Stop if no more ingredients
            break;
        }
    }

    const newInnerHTML = `
        &amp;lt;div id="rowa" id="cocktail-dataa"&amp;gt;
            &amp;lt;div id="five"&amp;gt;
                &amp;lt;img src="${cocktail.strDrinkThumb}" &amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div id="seven"&amp;gt;
               &amp;lt;h4&amp;gt;${cocktail.strDrink}&amp;lt;/h4&amp;gt;

               &amp;lt;div class="likes"&amp;gt; 
                  &amp;lt;button id="likeButton"&amp;gt;
                    &amp;lt;i class="fa fa-thumbs-up"&amp;gt;&amp;lt;/i&amp;gt;
                  &amp;lt;/button&amp;gt;
                  &amp;lt;input type="number" id="inputLike" value="0" name=""&amp;gt;likes&amp;lt;/input&amp;gt;
               &amp;lt;/div&amp;gt;


                &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Category:&amp;lt;/strong&amp;gt; ${cocktail.strCategory}&amp;lt;/p&amp;gt;
                &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Glass type:&amp;lt;/strong&amp;gt; ${cocktail.strGlass}&amp;lt;/p&amp;gt;
                &amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;Type:&amp;lt;/strong&amp;gt; ${cocktail.strAlcoholic}&amp;lt;/p&amp;gt;
                &amp;lt;h5&amp;gt;Ingredients:&amp;lt;/h5&amp;gt;
                &amp;lt;ul&amp;gt;
                    ${ingredients.map(ingredient =&amp;gt; `&amp;lt;li&amp;gt;${ingredient}&amp;lt;/li&amp;gt;`).join('')}
                &amp;lt;/ul&amp;gt;
                &amp;lt;h5&amp;gt;Instructions:&amp;lt;/h5&amp;gt;
                &amp;lt;p&amp;gt;${cocktail.strInstructions}&amp;lt;/p&amp;gt;

            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;

    `;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can go ahead and click on the getcocktail button to display a random cocktail on the screen.&lt;/p&gt;

&lt;p&gt;Also, we use the click event listener to allow the user to add likes to the cocktails they like most&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    cocktail_container.innerHTML = newInnerHTML;
    let likebtn = document.querySelector('#likeButton');
    let inputLike= document.querySelector('#inputLike');

    likebtn.addEventListener('click', () =&amp;gt; {
    inputLike.value = parseInt(inputLike.value) + 1;
    // inputLike.style.color = "#12ff00";
})

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
