I am trying to import a profile pic to my app, and it is a real hit or a miss as to whether or not it renders. My console log's that the photo is getting sent but it won't always show up. When it doesn't show, I get hit with this error:
TypeError: undefined is not an object (evaluating 'response.photo_data.raw_data')]
Where: 'response.photo_data.raw_data' is server the function that carries the image data.
Below is the code I use to import the photo, as well as the information associated with the profile (which also comes from the server.) Any suggestions are helpful. I am running in Expo Managed Workflow.
Function that pulls data from server to the app
useEffect(() =>{
const displayPhoto = async () => {
let response = await
client_instance.download_profile_photo()
getImageData(response.photo_data.raw_data)
}
displayPhoto()
}
How photo is displayed in the app:
<View>
{imageData && <Avatar.Image source={{uri:`data:image/jpg;base64,${imageData}`}}/>}
</View>