Promise Syntax
Learn to create Promises in JavaScript with functions, callbacks, and error handling.
We'll cover the following
The code examples that we have seen up until now have used Promises that are
provided by a third-party library, such as the Promise-based versions of filesystem access available through the Node fs.promise
namespace. So, how do we write our own Promises?
Writing Promises
A Promise is an instance of a new Promise class whose constructor requires a
function signature that accepts two callback functions, generally named resolve
and reject
.
Consider the following function definition:
Get hands-on with 1400+ tech skills courses.