How to convert callback function to promise in nodejs code example
Example: convert functoin with call back to promise
const readFilePromise = () => {
return new Promise((resolve, reject) => {
fs.readFile(filePath, options, (err, data) => {
if (err) return reject(err)
resolve(data)
})
})
}