diff --git a/using-fetch/exercise.js b/using-fetch/exercise.js index 34be09e2..4c5f9814 100644 --- a/using-fetch/exercise.js +++ b/using-fetch/exercise.js @@ -17,10 +17,14 @@ 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 ***") +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 - }); + let greetingMessage = document.getElementById("greeting-text"); + greetingMessage.textContent = `${greeting.greeting}!, which means "Hello" in ${greeting.language} language :)`; + }) + .catch((error) => + console.error("Sorry, failed to download greeting ", error) + );