Thanks for seeing my post!
Below is my array which is changed by another script after some time
export const bookFiles=[]
I have imported it in my main Express JS + Node JS route for an api, But the problem is that when I run the script it takes and remembers the values in the array and provide that to the api fetch. But I want it to re-import or re-scan the array and send it to the API fetch.
Router File:
routes/book.mjs:
import express from "express";
export const book = express.Router();
import { bookFiles } from "../Arrays/bookFiles.mjs";
book.get("/",(req,res)=>{
const data=bookFiles
res.send(data)
}
)
And this is my Main File
/app.mjs:
import express from 'express';
import { zip } from './routes/zip.mjs';
import { office } from './routes/office.mjs';
import { compressed } from './routes/compressed.mjs';
import { image } from './routes/images.mjs';
import { book } from './routes/book.mjs';
import { videos } from './routes/videos.mjs';
var app = express()
app.use("/zipFiles",zip)
app.use("/officeFiles",office)
app.use("/videoFiles",videos)
app.use("/compressedFiles",compressed)
app.use("/bookFiles",book)
app.use("/imageFiles",image)
app.listen("5000")
I also tried to instead readFileSync from .js file and then parse it into Array, but it didn’t worked because JSON.parse() does not support it. Thanks for the cooperation.