NodeJS http.request not returning data even after specifying return on the 'end' event

前端 未结 3 2179
鱼传尺愫
鱼传尺愫 2020-12-12 05:47

Basically I am trying to scrap some data from website and perform the DOM extraction, deletion and updation on a callback function binded to the \'end\' event of http.

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-12 06:42

    Is your 'var scraper' also in the route.js file? I guess it's not and you are unable to access that other js file, for doing so use module.exports.

    eg.

    // module.js
    var name = "foobar";
    // export it
    exports.name = name; 
    
    
    
    Then, in route.js...
    >      //route.js
    >      // get a reference to your required module
    >      var myModule = require('./module'); 
    >      //correct path to folder where your above file is
    >      // name is a member of myModule due to the export above
    >      var name = myModule.name;
    

提交回复
热议问题