Skip to content

Commit

Permalink
fix the bug that made double callback
Browse files Browse the repository at this point in the history
  • Loading branch information
ohsc committed Oct 23, 2012
1 parent e0a6beb commit 620d7b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "dnspod-client",
"version": "0.1.0",
"version": "0.1.1",
"description": "A DNSPOD Client",
"keywords": [
"dnspod", "ddns", "get ip"
Expand Down
12 changes: 9 additions & 3 deletions src/dnspod.js
Expand Up @@ -56,9 +56,15 @@ Dnspod.prototype.request = function(url, params, eventListenerName){
}).on('end', function() {
try {
var jsonData = JSON.parse(resData.join(''));
self.emit(eventListenerName, null, jsonData);
} catch (ex) {
self.emit(eventListenerName, new Error('Request failed'));
console.log(ex);
var err = ex;
} finally {
if(err) {
self.emit(eventListenerName, new Error('Request failed'));
} else {
self.emit(eventListenerName, null, jsonData);
}
}
});
};
Expand Down Expand Up @@ -176,4 +182,4 @@ function mergeJSON(obj1, obj2) {
return obj1;
}

module.exports = Dnspod;
module.exports = Dnspod;

0 comments on commit 620d7b5

Please sign in to comment.