Last active
February 24, 2020 02:03
-
-
Save dongseok0/9312eacc2db52e2f8846d39c08088465 to your computer and use it in GitHub Desktop.
Promisify Azure storage service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use function that Async keyword appended | |
Bluebird.promisifyAll(blobService, { | |
promisifier: (originalFunction) => function (...args) { | |
return new Promise((resolve, reject) => { | |
try { | |
originalFunction.call(this, ...args, (error, result, response) => { | |
error && reject(error); | |
resolve({result, response}); | |
}); | |
} catch (e) { | |
reject(e); | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Got it working - didn't know I had to put Async on the end of any functions that have been promisified e.g. tableService.retrieveEntityAsync().then(