Skip to content
Snippets Groups Projects
Commit dcf37cfb authored by Prasad Bhat's avatar Prasad Bhat
Browse files

used fs and async await for file creation

parents
No related branches found
No related tags found
No related merge requests found
index.js 0 → 100644
const fs = require("fs").promises;
const createFile = async () => {
try {
await fs.writeFile("example.txt", "This is an example file created using fs module and async/await.");
console.log("File created successfully!");
} catch (error) {
console.error("Error creating file:", error);
}
};
createFile();
\ No newline at end of file
{
"name": "files_async",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment