LearnApplyShare

[Nodejs] 프라미스 파일쓰기

December 11, 2018 - [nodejs, file, promise]

it works

const util = require('util')
const fs = require('fs');
const fs_writeFile = util.promisify(fs.writeFile)

fs_writeFile('message.txt', 'Hello Node.js')
.catch((error) => {
    console.log(error)
});

Ref.

https://stackoverflow.com/questions/31978347/fs-writefile-in-a-promise-asynchronous-synchronous-stuff