Home > Blockchain >  NodeJS Passing Express res to completely different module
NodeJS Passing Express res to completely different module

Time:11-20

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

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()


}

CodePudding user response:

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

  • Related