Fix callback invokation

This commit is contained in:
Girish Ramakrishnan
2017-10-04 19:08:07 -07:00
parent 3fb5034ebd
commit b9efb0b50b

View File

@@ -52,9 +52,11 @@ function getCaasCredentials(apiConfig, callback) {
assert(apiConfig.token);
if ((new Date() - gCachedCaasCredentials.issueDate) <= (1.75 * 60 * 60 * 1000)) { // caas gives tokens with 2 hour limit
return gCachedCaasCredentials.credentials;
return callback(null, gCachedCaasCredentials.credentials);
}
debug('getCaasCredentials: getting new credentials');
var url = config.apiServerOrigin() + '/api/v1/boxes/' + config.fqdn() + '/awscredentials';
superagent.post(url).query({ token: apiConfig.token }).timeout(30 * 1000).end(function (error, result) {
if (error && !error.response) return callback(error);