How to Create Cat Fact application Using Free Api

Hello friends in this article i am gone to share How to Create Cat Fact application Using Free Api with you..
How to Create Cat Fact application Using Free Api
Visit This Link to See Demo 
To Build This Type of application You Need Some Basic knowledge just Like 
  1. HTML
  2. CSS,
  3. JavaScript
Free Cat Fact Api link– Copy this link
Follow My Steps to Create beautiful application like that



Step 1) First Create basic Html Template like that
<!DOCTYPE html>
    <title>Page Title</title>
    <h1>Cat Fact </h1>
     <p>This is a paragraph.</p>
Step 2) Use Some Basic CDN links to Make Page More attractive
in This i Use 2 CDN links
  • Bootstrap 5
  • Google Fonts

Copy this CDN links and Put on Head tag. / Bootstrap 5


<!-- Bootstrap CSS -->     
<link href="" rel="stylesheet">
—————————————————————————————————————————————-</span >

Copy this CDN links and Put on Head tag. / Google Fonts

<!-- Google Fonts CSS --> 
<link rel="preconnect" href=""> 
<link rel="preconnect" href="" crossorigin> 
<link href="" rel="stylesheet"> 

Now Our Html Page Look Cool

Step 3) Replace all the Code inside body from this Code..
In This Code i Created a Simple Card..
<div class="container shadow mt-5 p-2 rounded bg-white border">
<div class="d-flex justify-content-between">
<div class="">
<p class="mt-3 ms-3 datep" id="date">Date</p>
<div class=""> 
<button type="button" class="btn btn-primary btn-sm m-2 p-2 shadow-sm" onclick="fetchText()"> Refresh </button> 
<h1 class="text-center mb-3">Cat Facts</h1>
<div class="d-flex justify-content-between p-4">
<div class="p-0 ms-1"> <img id="myImg" src=""/> </div>
<div class="p-0 ms-3">
<p id="demo" class="b"> </p>
<p id="error"> </p>

Now Our Html Page Look Cool
Step 4) Add This Css Code Head Tag.
This Code make our card more attractive.
<style>* {
font-family: 'Comfortaa', cursive;

body {
background-color: #A2D2FF;

.container {
width: 650px;

img {
width: 200px;

.datep {
background-color: #97f7ada3;
padding: 5px;
font-size: 12px;
border-radius: 4px;

Now Add JavaScript to do Some Cool Stuff.
Step 5) Add This JavaScript Code in bottom of the HTML Page.
  • In This JavaScript i make a connection with api using async  function , when i click on Refresh button it always get back some response , then i store in a variable and show on Html Page.

   // Fetch api module 

   async function fetchText() {

      let response = await fetch('');

      console.log(response.status); // 

      console.log(response.statusText); // 

      if (response.status === 200) {

          let data = await response.json();

          // handle data



    var nfact = data.fact; </span > 

document.getElementById("demo").innerHTML = nfact;

    var rand = Math.floor(Math.random() * 4) + 1;


 </span >document.getElementById("myImg").src = "images/pic1.png";


    else if(rand==2){

 document.getElementById("myImg").src = "images/pic2.png";


    else if(rand==3){

document.getElementById("myImg").src = "images/pic3.png";


    else if(rand==4){

document.getElementById("myImg").src = "images/pic4.png";


 </span >document.getElementById("myImg").src = "images/pic2.png";







 </span >fetchText();

   }, 25000); 

   // Date Module  

   var today = new Date();

   var dd = today.getDate();

   var mm = today.getMonth()+1; 

   var yyyy = today.getFullYear();





   today = dd+'-'+mm+'-'+yyyy;


document.getElementById("date").innerHTML = today;
Now our Application is Ready. Refresh your Html Page and you will Get New fact Every Time & you can also change cat fact using refresh button.
Follow me For this type of Cool Stuff.
See Demo App go to this Link:
Download Full Source code from this Link