are you sure authenticate function? Your code is seems to be perfect. There is two thing you have to do
1.Make callback on request error, request timeout and request abort.
2.Get deep insight about your callback, In following code you call same function on throwing exception. Are you sure about this?. This could make possibly loop, if it is again reach "authentication" function.
try {
callback(JSON.parse(data));
} catch(e) {
callback();
console.log("authentication failed");
}