bluebird Converting a callback API to promises. Converting a single NodeJS function

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!


You can convert a single function with a callback argument to a Promise-returning version with Promise.promisify, so this:

const fs = require("fs");
fs.readFile("foo.txt", (err, data) => {
   if(err) throw err;


const promisify = require("bluebird");
const readFile = promisify(require("fs").readFile));
readFile("foo.txt").then(console.log); // promisified version

Got any bluebird Question?