Skip to content

Commit

Permalink
fix: getAuthorization 出错时能把日志打印在输入框中
Browse files Browse the repository at this point in the history
  • Loading branch information
wonderswang committed Apr 27, 2021
1 parent 6a57ed0 commit 7e823bb
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ var getAuthorization = function (options, callback) {
var credentials = data.credentials;
} catch (e) {
}
if (!data || !credentials) return console.error('credentials invalid');
if (!data || !credentials) {
return logger.error('credentials invalid:\n' + JSON.stringify(data, null, 2))
};
var authorization = COS.getAuthorization({
SecretId: credentials.tmpSecretId, // 可传固定密钥或者临时密钥
SecretKey: credentials.tmpSecretKey, // 可传固定密钥或者临时密钥
Expand Down Expand Up @@ -89,7 +91,9 @@ var getAuthorization = function (options, callback) {
// var credentials = data.credentials;
// } catch (e) {
// }
// if (!data || !credentials) return console.error('credentials invalid');
// if (!data || !credentials) {
// return logger.error('credentials invalid:\n' + JSON.stringify(data, null, 2))
// };
// callback({
// TmpSecretId: credentials.tmpSecretId,
// TmpSecretKey: credentials.tmpSecretKey,
Expand Down Expand Up @@ -936,7 +940,7 @@ function getObject() {
Bucket: config.Bucket, // Bucket 格式:test-1250000000
Region: config.Region,
onProgress: function (progressData) {
console.log(JSON.stringify(progressData));
logger.log(JSON.stringify(progressData));
}
}, function (err, data) {
logger.log(err || data);
Expand Down Expand Up @@ -1397,8 +1401,7 @@ function request() {
Query: {},
Body: '',
}, function (err, data) {
console.log('err:', err);
console.log('data:', data);
logger.log(err || data);
});
}

Expand Down

0 comments on commit 7e823bb

Please sign in to comment.