Let’s recap on the concepts covered in the previous exercises:
GET and POST requests can be created a variety of ways.
Use AJAX to asynchronously request data from APIs.
awaitare new functionalities developed in ES6 (promises) and ES8 respectively.
fetch()is a web API that can be used to create requests.
fetch()will return promises.
We can chain
.then()methods to handle promises returned by
.json()method converts a returned promise to a JSON object.
asyncis a keyword that is used to create functions that will return promises.
awaitis a keyword that is used to tell a program to continue moving through the message queue while a promise resolves.
awaitcan only be used within functions declared with
Congratulations on learning all about AJAX requests using
await! These concepts are fundamental and will help you develop more robust web apps!
Play around with the browser and code to make GET and POST requests. If you’re going to make POST requests, 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 methods with your own code.
- Use different APIs to make GET/POST requests using