Skip to content

Commit

Permalink
fetch last tabs file
Browse files Browse the repository at this point in the history
  • Loading branch information
casper392945 committed Mar 7, 2024
1 parent f1d85c3 commit f44be1f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions assets/data/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit f44be1f

Please sign in to comment.