Skip to content

Commit

Permalink
Implemented IIFE function to get UserAvatar image src URL
Browse files Browse the repository at this point in the history
  • Loading branch information
wrigh393 committed Mar 31, 2021
1 parent b6866e8 commit fa846eb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/UserAvatar/UserAvatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ export default function UserAvatar({ name, alias }) {
const [userImageURL, setUserImageURL] = useState([]);

useEffect(() => {
const getImageURL = async () => {
const response = await fetch(`https://engineering.purdue.edu/ECN/PersonPhotos/getPhoto?json=1&alias=${alias}`);
(async () => {
const response = await fetch(`https://engineering.purdue.edu/ECN/PersonPhotos/getPhoto?json=1&alias=${alias}`)
const jsonResponse = await response.json();
setUserImageURL(jsonResponse);
};
getImageURL();
})();
// const getImageURL = async () => {
// const response = await fetch(`https://engineering.purdue.edu/ECN/PersonPhotos/getPhoto?json=1&alias=${alias}`);
// const jsonResponse = await response.json();
// setUserImageURL(jsonResponse);
// };
}, [alias])

return (
Expand Down

0 comments on commit fa846eb

Please sign in to comment.