Get data from fs.readFile

前端 未结 15 2375
滥情空心
滥情空心 2020-11-22 15:38
var content;
fs.readFile(\'./Index.html\', function read(err, data) {
    if (err) {
        throw err;
    }
    content = data;
});
console.log(content);
         


        
15条回答
  •  逝去的感伤
    2020-11-22 16:10

    The following is function would work for async wrap or promise then chains

    const readFileAsync =  async (path) => fs.readFileSync(path, 'utf8');
    

提交回复
热议问题