Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

NodeJS Passing Express res to completely different module

I have an program that susposed to load js to server side dynamically by url (for organizing js files)

app.get('/*',function(req,res){
... path etc. code
    if(compare(list,path)){
        const js = require('/Js/'+list.find(x => x.pageUrl == path).js)
        js.run(req,res)
        
    }
... more code there
}

but for some reason passed res doesnt work and i get res.send is not defined error

here is the other module that i get path from url and load it

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

exports.run = function run(req,res)
{
    res.Send("test") //not defined for some reason
    console.log(res) //it is not undefined, i see stuff
    res.end()


}

>Solution :

Your code says res.Send instead of res.send.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading