Search code examples
javascriptnode.jsexpresswebpagetest

undefined is not a valid uri or options object. in expressjs


I am using expressjs, after running the webapagetest I am storing the url which is in string format in a variable then I am using this variable in request node module to get the data from that url, but I am getting undefined is not a valid uri or option. here is the my JavaScript code

 var WebPageTest = require('webpagetest');
    var wpt = new WebPageTest('url of private webpagetest instance server');

    wpt.runTest('https://google.com', function(err, data) {
        console.log(err || data);
        console.log(data.data.summaryCSV);
        sid = data.data.summaryCSV;
        console.log(typeof sid);

    });

    request(sid,function(error,response,body){
        console.log(body);

I am getting error at last line "request"

thanks.


Solution

  • Try for this:

    var WebPageTest = require('webpagetest'); 
    var wpt = new WebPageTest('server-url'); 
    wpt.runTest('some url', function(err, data) {
        console.log(err || data); 
        console.log(data.data.summaryCSV); 
        console.log("GOING INTO REQUEST MODULE!!"); 
        request('data_url', function (error, response, body) { 
           if (error) { 
          console.log(error); 
          } 
          console.log(body); 
          var data = body;
        })
    });