import { CameraView, useCameraPermissions } from 'expo-camera' import { useRef, useState } from 'react' import { Button, Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native' export default function App() { const [permission, requestPermission] = useCameraPermissions() const [photo, setPhoto] = useState('') const cameraRef = useRef(null) async function _takePhoto() { if (cameraRef.current) { const pic = await cameraRef.current.takePictureAsync() setPhoto(pic.base64 || '') } } async function sendData() { await fetch('http://localhost:3000/api/v1/posts', { method: 'POST', headers: { Accept: 'application/json, text/plain, */*', 'Content-Type': 'application/json' }, body: JSON.stringify({ userID: '6883ddb2640ebaa1a12e3791', date: new Date(), photo: photo, notes: '3333 W Smoochie St' }) }) } if (!permission) { // Camera permissions are still loading. return } if (!permission.granted) { // Camera permissions are not granted yet. return ( We need your permission to show the camera