Great job making it this far!
In the previous exercise, you created the query URL, called the
fetch() function and passed it the query URL and a settings object. Then, you chained a
.then() method and passed it two functions as arguments — one to handle the promise if it resolves, and one to handle network errors if the promise is rejected.
In this exercise, you’ll now take the information that was returned with the promise and manipulate the webpage!
At the end of the
.then() method, chain another
.then() an anonymous arrow callback function that takes
jsonResponse as its single parameter.
Inside the callback function, call the function
renderRawResponse() and pass in
jsonResponse as an argument. Run the code.
In the input field, you can type in a word and click the submit button.
If all went well, you should see an array of words that the Datamuse API responded with!
You can view the purpose of
renderRawResponse at public/helperFunctions.js.
Time to clean up that response a bit.
renderRawResponse(jsonResponse) and replace it with
Run your code.
Try the webpage again with another word!