码迷,mamicode.com
首页 > 其他好文 > 详细

node fs 解决回调地域问题

时间:2019-03-16 12:54:42      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:NPU   cti   log   test   bsp   问题   syn   sync   nod   

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)

}

}

node fs 解决回调地域问题

标签:NPU   cti   log   test   bsp   问题   syn   sync   nod   

原文地址:https://www.cnblogs.com/joer717/p/10541650.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!