diff --git a/public/js/editplaceselection.js b/public/js/editplaceselection.js index 86522c494867a27f4addf568c4401aa70834a76a..0a7fef9182a7fc45a037ba1b94ddf8209c76e031 100644 --- a/public/js/editplaceselection.js +++ b/public/js/editplaceselection.js @@ -81,8 +81,32 @@ document.addEventListener("DOMContentLoaded" , async () => { newLink.href = "/edit-place-info?placeid="+place["PlaceID"]; var newImage = document.createElement("img"); - newImage.src = "../../public/package/purpletravel.jpg"; - newImage.alt = "destination1"; + fetch('/api/get-place-image', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + PlaceId: place["PlaceID"], + }), + }) + .then(response => { + console.log(response); + if (response.ok) { + return response.blob(); + } else { + throw new Error('Profile picture not found.'); + } + }) + .then(blob => { + const imageUrl = URL.createObjectURL(blob); + console.log("TESS" + imageUrl); + newImage.src = imageUrl; + newImage.alt = "destination1"; + }) + .catch(error => { + console.error('error getting profile image:', error); + }); var newH2 = document.createElement("h2"); newH2.textContent = place["PlaceName"];