make getSessionId & generateToken error first callback

getSessionId & generateToken should follow nodejs' native error-first callback pattern. This makes it easy to catch errors.
pull/30/head
talentedandrew 2018-03-02 12:41:21 +05:30 committed by GitHub
parent d5d383ce90
commit 8d8ad4b172
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -28,7 +28,7 @@ export class Session {
public getSessionId(callback: Function) {
if (this.sessionId) {
callback(this.sessionId);
callback(null, this.sessionId);
return;
}
@ -59,12 +59,13 @@ export class Session {
// Data reception is done
let parsed = JSON.parse(body);
this.sessionId = parsed.id;
callback(parsed.id);
callback(null, parsed.id);
});
});
req.on('error', (e) => {
console.error(e);
callback(e);
});
req.write(requestBody);
req.end();
@ -111,12 +112,13 @@ export class Session {
res.on('end', () => {
// Data reception is done
let parsed = JSON.parse(body);
callback(parsed.id);
callback(null, parsed.id);
});
});
req.on('error', (e) => {
console.error(e);
callback(e);
});
req.write(requestBody);
req.end();
@ -143,4 +145,4 @@ export class Session {
}
}
}
}