I am practicing AWS-S3 bucket and passing data from local to global scope. It's an simple Javascript concept. I have array of strings value which I am getting from S3 bucket. I can see my data when I console it. I am trying pass this data to global scope. I tried push method, spread operator but it did not work. Global scope gives me empty array. I don't get what I am doing wrong.
I get data from S3 bucket like this
["182363", "j9292092", "20282"]
I want pass my data to global variable exactly this.
this is my piece of code
const allSKU = []
await s3.getObject(params, function (err, data) {
if (err) console.log(err, err.stack);
// else console.log(data.Body.toString('utf-8')); // I can see the data
const allSku = data.Body.toString('utf-8')
//console.log(allSku);
allSKU.push(allSku)
});
console.log(allSKU); // give me empty arrays