title: How to retrieve list of objects (including the metadata associated with each object) from AWS S3 bucket using AWS Javascript SDK?
body: <p>I am trying to display a list of objects stored in my AWS S3 bucket on the front-end. I can easily retrieve the list of objects using the <a href="https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#listObjects-property" rel="nofollow noreferrer"><code>listObjects()</code></a> method. </p>
  
  <p>Only problem is that I have some metadata associated with each object that I also want to retrieve and display along with the list. The <strong><code>listObjects()</code></strong> method does not retrieve the metadata of each object. It seems the only way to retrieve the metadata of an object is by using the <a href="https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#headObject-property" rel="nofollow noreferrer"><code>headObject()</code></a> method. </p>
  
  <p>However, <strong><code>headObject()</code></strong> only fetches the metadata of one object at a time and it obviously requires me to iterate over the list of objects returned by <strong><code>listObjects()</code></strong> and then retrieve the metadata for each object using <code>headObject()</code>. I was wondering if there is a way to retrieve the list of objects plus the metadata associated with each object with one API call? The solution mentioned above works but slows down the performance of the application considerably.</p>