'How to make code run every request for a GET api

const http = require('http');
const url = require('url');
const fs = require("fs");

const host = 'ip';
const port = 1234;

let requestListener = function (req, res) {
    //some code
};


const server = http.createServer(requestListener);
server.listen(port, host, () => {
    console.log(`Server is running on http://${host}:${port}`);
});

Is it possible to make the code in requestListener run every time someone makes a request? Currently its just when the program runs for the first time, then if there's something in there, such as reading from a file, and it won't update.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source