When we get the value back from a promise, it is known as settling the promise. We execute the promise using the then method. Here is the syntax…
The then method takes two arguments. The first one is a function to run when the promise is returned/resolved. The second is a function to run when a promise is rejected or an error has occurred.
If you run the code, you will see “fulfilled: a value” outputted to the console. Change the resolve in setTimeout to reject and you will see that the error code runs.