From 86160fcceeef0501e875d0fd8863433556f9449f Mon Sep 17 00:00:00 2001 From: "MD.AL-AMIN" <101187208+alaminAppnap@users.noreply.github.com> Date: Mon, 25 Sep 2023 12:07:12 +0600 Subject: [PATCH] updated --- SMS/message-history.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SMS/message-history.js b/SMS/message-history.js index 64e0b56..368a873 100644 --- a/SMS/message-history.js +++ b/SMS/message-history.js @@ -37,7 +37,11 @@ async function smsHistoryCreateOnFile(message,phoneNumber,response,csmsId){ if (fs.existsSync(filePath)) { const fileData = fs.readFileSync(filePath, 'utf-8'); - existingData = JSON.parse(fileData); + if (typeof fileData === 'object') { + existingData = fileData; + } else { + existingData = JSON.parse(fileData); + } } existingData.push(newJsonObject);