From f44be1fc9f9fa8ebd57daab4b92e655fba74de38 Mon Sep 17 00:00:00 2001 From: casper392945 Date: Thu, 7 Mar 2024 12:58:30 +0600 Subject: [PATCH] fetch last tabs file --- assets/data/script.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/assets/data/script.js b/assets/data/script.js index e1b92dc..18ad7e8 100644 --- a/assets/data/script.js +++ b/assets/data/script.js @@ -15,6 +15,32 @@ function fetchData(inputValue) { // Perform data fetching using the inputValue // console.log("Fetching data for:", inputValue); // ...rest of the code + const fs = require('fs'); + const path = require('path'); + + const directoryPath = 'assets/data'; + + fs.readdir(directoryPath, (err, files) => { + if (err) { + console.error('Error reading directory:', err); + return; + } + + const filteredFiles = files.filter(file => file.endsWith('-tab.json')); + const lastFile = filteredFiles[filteredFiles.length - 1]; + + const filePath = path.join(directoryPath, lastFile); + console.log('Last file:', lastFile); + + fs.stat(filePath, (err, stats) => { + if (err) { + console.error('Error getting file stats:', err); + return; + } + console.log('Last modified date:', stats.mtime); + }); + }); + fetch("assets/data/tabs2json.json", { method: "GET", headers: {