From bb61e86006bbe853e40b2a5255f5f3e173c585b5 Mon Sep 17 00:00:00 2001 From: Yesna-Omar <109865751+Yesna-Omar@users.noreply.github.com> Date: Wed, 31 May 2023 01:48:46 +0100 Subject: [PATCH] Update exercise.js --- using-fetch/exercise.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/using-fetch/exercise.js b/using-fetch/exercise.js index 34be09e2..81bf34d7 100644 --- a/using-fetch/exercise.js +++ b/using-fetch/exercise.js @@ -17,10 +17,15 @@ Open index.html in your browser. Every time you refresh the page, a different greeting should be displayed in the box. */ -fetch("*** Write the API address here ***") + let greetingElement =document.getElementById("greeting-text"); + +fetch("https://www.greetingsapi.com/random") .then(function (response) { - return response.text(); + return response.json() }) .then(function (greeting) { // Write the code to display the greeting text here + + greetingElement.innerText=`${greeting.greeting} that's greeting in ${greeting.language} `; + });