replace your comments and 1 line above & below the comments with the following code
var vertices = poly.getPath();
var polygonBounds = [];
for (var i = 0; i < vertices.length; i++) {
var xy = vertices.getAt(i);
polygonBounds.push({ lat: xy.lat(), lon: xy.lng() });
}
console.log(polygonBounds);
hope this work fine for you.