What could cause “connect ETIMEDOUT” error when the URL is working in browser?

后端 未结 6 1438
深忆病人
深忆病人 2021-02-19 07:46

I train myslef with NodeJS and tried a simple GET call. Here is my code:

var http = require(\'http\');

var options = {
    host: \'www.boardgamegeek.com\',
             


        
6条回答
  •  执笔经年
    2021-02-19 08:07

    The following change with the request worked for me:

     var options = {
             proxy:'PROXY URL', 
             uri: 'API URL',
             method: 'GET' 
             }
     request(options, function (err, response, body) {
         if(err){
            console.log('error:', err);
           } else {
         console.log('body:', body);
          }
       });
    

提交回复
热议问题