Summary
Throughout this chapter, we practiced how to use async
/await
when fetching data from a server. We also covered how to catch errors by using the try
/catch
pattern followed by how to use async
/await
inside loops. Firstly, we learned what a promise is and how to use it with three methods, then()
, finally()
, and catch()
. Also, we discovered how to use Axios
to use these three methods. After that, in the exercise, we practiced how to fetch data from OpenWeather
API using Axios
with then()
, finally()
, and catch()
. After that, we dived into async
/await
by discussing what the async
and await
keywords are for. And then we talked about how to use then()
, error()
, and finally()
methods with async
/await
, followed by an example of a benefit of using async
/await
over Promise while handling errors. In addition, we discussed how to use async
/await
within loops and saw an example of when to use for…of
and map()
, and also why the forEach()
method is not recommended.
Having a good...