Skip to content

Latest commit

 

History

History
24 lines (22 loc) · 819 Bytes

README.md

File metadata and controls

24 lines (22 loc) · 819 Bytes

quote-app

an web-app which displays quotes using api data

About concept

  • its fetches the api and display the quotes in container.
  • with the help of body tag and display (flex) properties i have centered both div and content.
  • in javascript i used the DOM (Document Object Model) concept to display that data on a webpage.
  document.addEventListener('DOMContentLoaded', function () {
  fetch('https://random-api.xyz/api/fun/quote')
    .then(response => response.json())
    .then(data => {
      const apiDataElement = document.getElementById('apiData');
      apiDataElement.textContent = JSON.stringify(data.quote);
      console.log(data);
    })
    .catch(error => {
      console.error('Error fetching API data:', error);
    });
  });

API