portfolio/src/main/webapp/script.js
/** Sends a GET request to the server at '/serve-images' URL
 * to retreive image submitted with comment, if any.
 * @param blobKey the string that is the BlobKey (blobstore key) of 
 *     the stored image blob
 * @returns a URL string that is the URL of the stored image, or null if 
 *     blobKey is null or undefined if image is not found
 */
Sends a GET request to the server at '/serve-images' URL
to retreive image submitted with comment, if any.
@param blobKey the string that is the BlobKey (blobstore key) of
the stored image blob
@returns a URL string that is the URL of the stored image, or null if
blobKey is null or undefined if image is not found
Sends a GET request to the server at ' / serve - images ' URL to retreive image submitted with comment if any . @param blobKey the string that is the BlobKey ( blobstore key ) of the stored image blob @returns a URL string that is the URL of the stored image or null if blobKey is null or undefined if image is not found
async function fetchCommentImage(blobKey) {
  if (blobKey == null) {
    return null;
  }
  const response = await fetch(`/serve-images?blob-key=${blobKey}`);
  if (response.ok) {
    const blob = await response.blob();
    const imageURL = window.URL.createObjectURL(blob);
    return imageURL; 
  }
  else {
    console.log("Error fetching image: " + response.status + " " + response.statusText);
    return undefined;
  }
}
async function fetchCommentImage ( blobKey ) { if ( blobKey == null ) { return null ; } const response = await fetch ( ` ${ blobKey } ` ) ; if ( response . ok ) { const blob = await response . blob ( ) ; const imageURL = window . URL . createObjectURL ( blob ) ; return imageURL ; } else { console . log ( "Error fetching image: " + response . status + " " + response . statusText ) ; return undefined ; } }
Sends a GET request to the server at '/serve-images' URL
 to retreive image submitted with comment, if any.
Sends a GET request to the server at ' / serve - images ' URL to retreive image submitted with comment if any .
// check that response was successful // parse the body of the response as a Blob. // create a URL for accessing the Blob.