unhandledRejection - Using Promises - JavaScript | MDN
Thu Apr 01 2021 21:48:01 GMT+0000 (Coordinated Universal Time)
Saved by @pablomuro
One case of special usefulness: when writing code for Node.js, it's common that modules you include in your project may have unhandled rejected promises, logged to the console by the Node.js runtime. You can capture them for analysis and handling by your code—or just to avoid having them cluttering up your output—by adding a handler for the Node.js unhandledRejection event (notice the difference in capitalization of the name), like this:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises
Comments