https://github.com/Asabeneh/30-Days-Of-JavaScript/blob/master/18_Day_Promises/18_day_promises.md
- Promises are useful when performing a single asynchronous task
- Promises are based on
resolve and reject
, if itresolves
the.then
executes, if itrejects
we.catch
the error - Some APIs already have in-built promises as the the fetch API allowing to directly use
.then
and.catch
Async/Await
:async
make the function a promise, two blocks similar asresolve
andreject
:try
andcatch
, we put theawait
in thetry
block,await
allows to wait for the execution of a function before performing a task
Vanilla Javascript