In this lesson, we learned how to make GET and POST requests using the Fetch API and
await keywords. Let’s recap on the concepts covered in the previous exercises:
- GET and POST requests can be created in a variety of ways.
- We can use
awaitto asynchronous request data from APIs.
fetch()function can be used to create requests and will return promises.
- We can chain
.then()methods to handle promises returned by the
asynckeyword is used to create asynchronous functions that will return promises.
awaitkeyword can only be used with functions declared with the
awaitkeyword suspends the program while waiting for a promise to resolve.
Congratulations on learning all about asynchronous requests using
await! These concepts are fundamental to helping you develop more robust web apps!
Play around with the browser and code to make GET and POST requests. To make POST requests to the Rebrandly API, make sure you assign
apiKey your Rebrandly API key and run the code!
If you want to challenge yourself:
- Rewrite the requests from scratch.
- Replace the helper functions (
renderResponse()in public/helperFunctions.js) with your own code.
- Use different APIs to make GET/POST requests using