diff --git a/docs/API.md b/docs/API.md index 20f308a42..4b1d68053 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1607,27 +1607,27 @@ __Parameters__ | `callback(err)` | _function_ |Callback function is called with non `null` value in case of error. If no callback is passed, a `Promise` is returned. | -__Example__ +__Example 1__ Get Legal hold of an object. ```js minioClient.getObjectLegalHold('bucketName', 'objectName', {}, function(err, res) { if (err) { - return console.log('Unable to get legal hold config for the object', err) + return console.log('Unable to get legal hold config for the object', err.message) } console.log('Success', res) }) ``` -__Example 1__ +__Example 2__ Get Legal hold of an object with versionId. ```js minioClient.getObjectLegalHold('bucketName', 'objectName', { versionId:'my-obj-version-uuid' }, function(err, res) { if (err) { - return console.log('Unable to get legal hold config for the object', err) + return console.log('Unable to get legal hold config for the object', err.message) } console.log('Success', res) }) @@ -1656,7 +1656,7 @@ Set Legal hold of an object. ```js minioClient.setObjectLegalHold('bucketName', 'objectName', {Status:"ON"}, function(err, res) { if (err) { - return console.log('Unable to set legal hold config for the object', err) + return console.log('Unable to set legal hold config for the object', err.message) } console.log('Success') }) @@ -1668,7 +1668,7 @@ Set Legal hold of an object with versionId. ```js minioClient.setObjectLegalHold('bucketName', 'objectName', { Status:"ON", versionId:'my-obj-version-uuid' }, function(err, res) { if (err) { - return console.log('Unable to set legal hold config for the object version', err) + return console.log('Unable to set legal hold config for the object version', err.message) } console.log('Success') }) diff --git a/examples/get-object-legal-hold.js b/examples/get-object-legal-hold.js index 2c0de23d6..c9563f47a 100644 --- a/examples/get-object-legal-hold.js +++ b/examples/get-object-legal-hold.js @@ -28,7 +28,7 @@ var s3Client = new Minio.Client({ //Get Legalhold config s3Client.getObjectLegalHold('bucketName', 'objectName', {}, function(err, res) { if (err) { - return console.log('Unable to get legal hold config for the object', err) + return console.log('Unable to get legal hold config for the object', err.message) // Print only the message. } console.log(res) }) @@ -36,7 +36,16 @@ s3Client.getObjectLegalHold('bucketName', 'objectName', {}, function(err, res) { //With versionId s3Client.getObjectLegalHold('bucketName', 'objectName', { versionId:'my-obj-version-uuid' }, function(err, res) { if (err) { - return console.log('Unable to get legal hold config for the object', err) + return console.log('Unable to get legal hold config for the object', err.message) // Print only the message. } console.log(res) -}) \ No newline at end of file +}) + +//Promise based version: +const bucketTaggingPromise = s3Client.getObjectLegalHold('bucketName', 'objectName', { versionId:'my-obj-version-uuid' }) +bucketTaggingPromise.then((data) => { + console.log("Success...", data) +}) + .catch((e)=>{ + console.log(e.message) // Print only the message. e.g: "The specified object does not have a ObjectLock configuration" will be printed. + }) diff --git a/examples/set-object-legal-hold.js b/examples/set-object-legal-hold.js index 7ec1c1be4..0320639cb 100644 --- a/examples/set-object-legal-hold.js +++ b/examples/set-object-legal-hold.js @@ -30,7 +30,7 @@ s3Client.setObjectLegalHold('bucketName', 'objectName', {status:"ON"}, function( if (err) { return console.log('Unable to set legal hold config for the object', err) } - console.log('Success', res) + console.log('Success') }) //Set legal hold config of an object with versionId. @@ -38,5 +38,5 @@ s3Client.setObjectLegalHold('bucketName', 'objectName', { status:"ON", versionId if (err) { return console.log('Unable to set legal hold config for the object version', err) } - console.log('Success', res) + console.log('Success') }) \ No newline at end of file