So I've got a working node.js code that processes data from a website's API. I'd like to speed it up a bit and I figured the best way to do that would be to send a request and while waiting for a response some code would execute and not just wait for a response like it is now. Right now my code is essentially this:
function httpGet(url){
var response = requestSync(
'GET',
url
);
return response.body;
}
var returnCode;
var getUrl = "url"
returnCode = httpGet(getUrl);
var object = JSON.parse(returnCode);
//Some code executes
As you can see with this way some time is lost because you're waiting for the response. I'd be looking for something in this sense (pseudocode):
- Send a request
- Some code that's not related to the request is executed right after the request is sent
- After the part above is done the request result is parsed
In conclusion I'm looking for a way to send a request and not waste time waiting for a response. If you have any other ideas on how to speed up the code please let me know :)