I am not sure how to extract the data out of this function below. It is a function from aws-sdk I can see the console log, but I am not able to save it in a variable.. even if its a global variable.
I have always had trouble with this concept.. and if anyone could help me make more sense of it, that would be really great.
const listObjectsInBucket = (bucketName) => {
// Create the parameters for calling listObjects
let pdfList = ''
const bucketParams = {
Bucket: bucketName,
};
// Call S3 to obtain a list of the objects in the bucket
s3.listObjects(bucketParams, function (err, data) {
if (err) {
console.log("Error", err);
} else {
pdfList = data
// console.log("Success", data);
}
});
}
pdfList is undefined. :/