Skip to Content
Learn
Requests II
fetch() POST Requests V

You’re almost done with the POST request you started a few lessons back!

In fact, this time you’ll add another .then() to the chain to finally make the information available to your webpage!

If you reset the exercise at any point, you will have to paste in your API key again at the top!

Instructions

1.

Chain a .then() method to the end of the original .then() method.

2.

Pass in an anonymous arrow function as an argument for .then(). This callback function will take jsonResponse as its single parameter.

Inside the callback function, call renderRawResponse() and pass in jsonResponse.

Run the code.

Put in any URL in the text field, and then click the shorten button on the webpage. Make sure you include the entire link, including ‘http://‘ or ‘https://‘.

You’ll see the JSON of the response sent back from the API.

The renderRawResponse() helper function can be viewed at public/helperFunctions.js.

3.

Delete renderRawResponse(jsonResponse). In its place, call renderResponse() and passing in jsonResponse.

Run the code.

Put a URL into the text field again and then click the Shorten button on the web page. Notice the difference?

The renderResponse() helper function can be viewed at public/helperFunctions.js.

Folder Icon

Take this course for free

Already have an account?