Skip to content

Instantly share code, notes, and snippets.

@iDVB
Last active January 25, 2019 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iDVB/9aebf1fd49f732bb02f61458e48f81c1 to your computer and use it in GitHub Desktop.
Save iDVB/9aebf1fd49f732bb02f61458e48f81c1 to your computer and use it in GitHub Desktop.
async/await vs Promise
const doesKeyExist = async key => {
try{
const data = await S3.headObject({
Bucket: options.bucketName,
Key: key.replace(/^\/+/, ''),
}).promise();
return true;
}
.catch(err => err.statusCode === 404 ? false : throw err);
};
const doesKeyExist = key => S3.headObject({
Bucket: options.bucketName,
Key: key.replace(/^\/+/, '')
})
.promise()
.then(data => true)
.catch(err => err.statusCode === 404 ? false : throw err);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment