query an image from a dataset

Hi! Instead of using a hardcoded index of 3, you should use a loop to iterate over the results.items array and update the image for each item. You may want to add a check to make sure that the results object is not empty before attempting to access the items array.

Try out:

wixData.query("Purchase")
  .eq('user', id)
  .find()
  .then( (results) => {
    if (results.items.length > 0) {
      for (let i = 0; i < results.items.length; i++) {
        let item = results.items[i];
        let image = item.images;
        $w('#image1').src = image;
      }
    }
  })
  .catch( (error) => {
    // handle error
  });