[URGENT] Node.JS not working properly



  • // Please help! Need to enable node.js and install request module for this example.
    var request = require('request');
    request('http://www.google.com', function (error, response, body) {
    console.log('error:', error); // Print the error if one occurred
    console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
    console.log('body:', body); // Print the HTML for the Google homepage.
    });

    Some other module work but when I try this I get no output in BAS, works from node.js in command prompt. request module is installed in BAS as well as node.js installation from official source.


  • administrators

    @HELP_ME use await

    await(new Promise((resolve, reject) => {
        const request = require('request');
    
        request('https://community.bablosoft.com', function (err, res, body) {
            console.log(body);
            resolve()
        });
    }));