Now in order to actually do something when the promise gets either resolved or rejected, we need to call a promise method called then; somePromise.then. The then method lets us provide callback functions for both success and error cases. This is one of the areas where callbacks differ from promises. In a callback, we had one function that fired no matter what, and the arguments let us know whether or not things went well. With promises we'll have two functions, and this will be what determines whether or not things went as planned.
Now before we dive into adding two functions, let's start with just one. Right here, I'll call then, passing in one function. This function will only get called if the promise gets fulfilled. This means that it works as expected. When it does, it will get called with the value passed to resolve. In our case, it's a simple message, but it can be something like a user object in the case of a database request. For now though, we'll stick with message:
somePromise.then((message) => {
})
This will print message to the screen. Inside the callback, when the promise gets fulfilled we'll call console.log, printing Success, and then as a second argument, we'll print the actual message variable:
somePromise.then((message) => {
console.log('Success: ', message);
})