From 69bac5e240f415133261574d8565fc5edb0350c7 Mon Sep 17 00:00:00 2001
From: Nitesh Verma <nitesh.verma@niveussolutions.com>
Date: Wed, 26 Mar 2025 21:41:15 +0530
Subject: [PATCH] Write file function implemented

---
 index.js    | 15 +++++++++++++++
 message.txt |  1 +
 2 files changed, 16 insertions(+)
 create mode 100644 message.txt

diff --git a/index.js b/index.js
index f0ee39c..93f4ffe 100644
--- a/index.js
+++ b/index.js
@@ -1,3 +1,6 @@
+const fs = require('fs').promises;
+
+/// Promise method
 const displayMessage = () => {
     return new Promise((resolve, reject) => {
         setTimeout(() => {
@@ -9,3 +12,15 @@ const displayMessage = () => {
 // Calling the promise
 displayMessage().then(console.log).catch(console.error);
 
+// Creating a file using fs module
+const writeFile = async () => {
+    try {
+        await fs.writeFile("message.txt", "This file was created using fs module!");
+        console.log("File created successfully!");
+    } catch (error) {
+        console.error("Error creating file:", error);
+    }
+};
+
+// Calling the write file function
+writeFile();
\ No newline at end of file
diff --git a/message.txt b/message.txt
new file mode 100644
index 0000000..80ab35a
--- /dev/null
+++ b/message.txt
@@ -0,0 +1 @@
+This file was created using fs module!
\ No newline at end of file
-- 
GitLab