I\'m having a function returning a promise. In this function, we call a third party vender to send some push notification through their server.
it looks like
A different approach - useful if you want to do this sort of thing in many places
This bit is done once
Promise.prototype.thenWait = function thenWait(time) {
return this.then(result => new Promise(resolve => setTimeout(resolve, time, result)));
};
Then you can use it, like this usage for your example, anywhere
apiGetLoggedInUser.thenWait(3000).then(user => sendMessage(user.name));