Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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)
    })
  })
}
Source by zellwk.com #
 
PREVIOUS NEXT
Tagged: #convert #functoin #call #promise
ADD COMMENT
Topic
Name
3+2 =