Skip to content

Instantly share code, notes, and snippets.

@tonghuikang
Created August 27, 2019 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonghuikang/d99504e546f2e7963036d6b496bc181f to your computer and use it in GitHub Desktop.
Save tonghuikang/d99504e546f2e7963036d6b496bc181f to your computer and use it in GitHub Desktop.
Nodejs asynchronous read and write file
var parser = require("azure-func-multipart-parser");
var localImports = require("../modules/local-imports.js")
const FormData = require("form-data");
const fs = require('fs')
const { promisify } = require('util')
const readFileAsync = promisify(fs.readFile)
const writeFileAsync = promisify(fs.writeFile)
const run = async () => {
await writeFileAsync("/tmp/test/data.json", Buffer.from('Hello Node.js'));
const res = await readFileAsync('/tmp/test/data.json');
console.log(res)
}
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment