fix: improve loadReminder method to handle file reading errors and return empty array if file does not exist

This commit is contained in:
2026-04-29 17:25:58 +07:00
parent 3b26e06ffe
commit 3428ad6d1f

View File

@@ -249,8 +249,12 @@ class NotifikasiWaService {
}
async loadReminder() {
if (!fs.existsSync(filePath)) return [];
return JSON.parse(fs.readFileSync(filePath));
try {
const raw = await fs.readFile(filePath, 'utf-8');
return raw ? JSON.parse(raw) : [];
} catch (err) {
return []; // file belum ada
}
}
async deleteReminder(id) {