I've created a library for sending REST requests:
var rest = require('restler');
module.exports = {
beginSession: function()
{
var options = {
method: "GET",
query: {begin_session: '1'}};
rest.get('http://countly/i', options).
on('complete', function(data, response){
console.log('Status: ' + response.statusCode);
});
}
};
The problem is that every time I use the library and the call is responded, the 'on complete' is called multiple times: 1st use of method will call 'on complete' just once, 2nd use of method will call 'on complete' twice and so on....
What Am I doing wrong?
Thanks Jose