Retrieving the lotto numbers - Node.js
Suggesting you move to using promises instead of callbacks. This way, you don't have to do the tango with calling callbacks, collecting results and all. You can simply replace the request module with the request-promise module.

function getResult(options){
  ...
  return doRequest(options);
}

...

lotto(options).then(results =&gt; console.log(data), err =&gt; console.log(err));


There's little merit of putting doRequest inside getResults. It's only being used in getResults but it's not exposed anyways. Suggesting you move it out into the module.

JavaScript doesn't have default argument values (yet) but you can easily do the same thing using Object.assign. Provide a default object, and merge to a new object the defaults and the one from the arguments. This way, you avoid having to do a lot of default logic and value checks.

var defaults = {...}

function getResults(options){
  var mergedOptions = Object.assign({}, defaults, options);
  ...
}


Back to promises, firing multiple async calls in parallel using callbacks will require you to collect results and keep checking if all the requests have responded. When using Promises, you can easily use Promise.all to listen to an array of promises.

var request = require('request-promise');

function getResult(options){
  ...
  var drawRange = toDrawID - fromDrawID;

  // Create an array of drawIds and map them to promises
  var promises = Array(drawRange).fill(fromDrawID).map((fromDrawID, i) =&gt; {
    return request(url + (fromDrawID + i));
  });

  return Promise.all(promises);
}