node fs 解决回调地域问题

promisify问题

promisify = require('util).promisify

const read = promisify( fs.readFile);

read('input.txt').then(data=>{

  

}).catch(err=>{

})

async function test(){

     try{

         const  res = await read('input.txt')

      }catch(ex){

       console.log(ex)

}

}

猜你喜欢

转载自www.cnblogs.com/joer717/p/10541650.html