Skip to content

Commit

Permalink
Renammed state variable and function for getting image for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
wrigh393 committed Mar 22, 2021
1 parent 922d5d3 commit 66470c8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/components/UserAvatar/UserAvatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import PropTypes from "prop-types";
import { Avatar } from "@material-ui/core";

export default function UserAvatar({ name, alias }) {
const [userImage, setUserImage] = useState([]);
const [userImageURL, setUserImageURL] = useState([]);

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

return (
<Avatar src={`https://engineering.purdue.edu/${userImage.imagePath}`}>
<Avatar src={`https://engineering.purdue.edu/${userImageURL.imagePath}`}>
{name === "" ? null : name.charAt(0)}
</Avatar>
);
Expand Down

0 comments on commit 66470c8

Please sign in to comment.