How can I convert an image selected from imagepicker into base64 before sending it to graphql?
I set useState varaibles to set
const [image, setImage] = useState(null);
What can i do here to convert?
const choosePhotoFromLibrary = async() => {
const permissionResult = await ImagePicker.requestMediaLibraryPermissionsAsync();
if (permissionResult.granted === false) {
alert("Permission to access camera roll is required!");
return;
}
const pickerResult = await ImagePicker.launchImageLibraryAsync();
if(!pickerResult.cancelled) {
setImage(pickerResuls.uri);
}
then I grab the image from and set it to the useState varaible
<View style={styles.picContainer}>
<AddPicButton
onPress= {choosePhotoFromLibrary}
image= {image}
/>
<Text style={styles.bottomText}>ADD A PICTURE</Text>
</View>