calling data callback on res.on('end') in order to avoid data loss

I ve added some code to first write the full response and give it back to the dataCallback function when all data is recieved. Otherwise on data extensive calls its getting called for each chunk and breaks the JSON response