The below code not returning amazon s3 content, it works when console the data value. I have tried declare variable outside function and tried to return from function still, not works
const getMeridianToken1 = () =>{
  s3 = new aws.S3();
  // Create the parameters for calling listObjects
  var bucketParams = {
    Bucket: 'bucket-name',
    Key: 'access_token.json'
  };
  // Call S3 to obtain a list of the objects in the bucket
  s3.getObject(bucketParams, function(err, data) {
    if (!err) {
      var result = JSON.parse(data.Body.toString());
      console.log("working here---",result.access_token);
      return result.access_token; //this is not returning
    }
  });
  //return JSON.parse(data.Body.toString()); //if hard code here it works, if i return s3 conteent the data variable not available here
}
console.log("not working",getMeridianToken1);
 
     
    