finished js function that retrieves all photo data