From a285aa61749ed0e72fdc5ff035d5e3e4249975b5 Mon Sep 17 00:00:00 2001 From: Abhay Date: Wed, 15 May 2024 11:17:31 +0530 Subject: [PATCH] Update README.md --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 11a7a01..8706966 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,24 @@ # 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. +```js + document.addEventListener('DOMContentLoaded', function () { + fetch('https://random-api.xyz/api/fun/fortune') + .then(response => response.json()) + .then(data => { + const apiDataElement = document.getElementById('apiData'); + apiDataElement.textContent = JSON.stringify(data.fortune); + console.log(data); + }) + .catch(error => { + console.error('Error fetching API data:', error); + }); + }); +``` + +### API +- [link to api](https://docs.random-api.xyz)