I am trying to serve images from an "images" file in my project depending on the parameters that the user enters.
For example,
https://localhost:3000/images?fileName=burger
should display the image on the browser
does anyone know how i can go about it?
My structure is as follows:
images ---burger.jpg src ---index.ts
I tried to do it this way but for some reason it won't work
app.use('/images', express.static('images')); if(req.query.fileName === "burger"){ res.sendFile("burger.jpg" , {root: path.join("./images")}); }