You must provide callbacks to the Promise constructor so that it knows what to do when you allow or decline the operation.
For instance:
var p = new Promise((resolve, reject) => { setTimeout(() => { resolve(); }, 5000); }); p.then(() => { console.log("Got it"); })
After 5 seconds, the message Got it
appears in the console.
There is a very good library for Promises: Bluebird
Check out the Google developer documentation.
source share