node.js - request - How to “emitter.setMaxListeners()”?

前端 未结 7 1684
忘了有多久
忘了有多久 2020-11-28 06:27

When I do a GET on a certain URI using the node.js \'request\' module;

var options = {uri:\"aURI\", headers:headerData};
request.get(options, function (error         


        
7条回答
  •  失恋的感觉
    2020-11-28 06:38

    Although adding something to nodejs module is possible, it seems to be not the best way (if you try to run your code on other computer, the program will crash with the same error, obviously).

    I would rather set max listeners number in your own code:

    var options = {uri:headingUri, headers:headerData, maxRedirects:100};
    request.setMaxListeners(0);
    request.get(options, function (error, response, body) {
    }
    

提交回复
热议问题