re: How to rewrite a callback function in Promise form and async/await form in JavaScript VIEW POST


Use bluebirds .from callback function to easily to await on a function that takes a callback).

This only works if your callbacks are called in the standard way though, ie (err, result).

const Promise = require('bluebird');

await Promise.fromCallback(callback => functionThatTakesACallback(arg1, arg2, callback));

code of conduct - report abuse