Refactor http requests code in kronos.js