Seems like Node has no trouble exporting functions, but string variables are not so easy. In the code below, when I attempt to access long_url in index.js it interpolates as undefined in the pug template:
There is another issue because the output is blank now. I just tested using another file to export a string variable and it did output correctly though. So something, probably my get request code, is wrong.
The problem is with your export. long_url is never set to anything, you’re creating a new variable with const long_url instead of reusing that one you exported.
I think the premise is wrong in the first place, by doing this you’re kind of using global variables. I don’t think this will work, but it may if you’re using webpack. The problem is that when index.js reads long_url it is empty, it won’t change later when router.get('/'... is called in url.js.
Why are you grabbing long_url from urls.js? Can’t you get it from the req inside router.get('/result')?