Posts

Showing posts with the label http-get

nodejs http.request how to collect data

nodejs http.request how to collect data I am trying to invoke a rest API URL in one method and then use that response to form the next query to another URL, let's say git to query some information. I have seen numerous examples before posting this, in everyone people are simply printing the response to console or setting it to the server response. I have tried using async/await but it just makes the whole thing really slow. So, I am not so keen on using that approach. I am doing the callbacks but I am not able to collect data to actually loop over it. Here is my code snippet:- function initialize(path) { // Setting URL and headers for request var options = { url: '', headers: { 'Accept': '*/*', 'User-Agent' : 'something something', 'Authorization': 'Basic ' + new Buffer(process.env.username + ':' + process.env.password).toString('base64') }, ...