import { CameraView, useCameraPermissions } from 'expo-camera' import React, { useRef, useState } from 'react' import { Button, Image, StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native' export default function App() { const [permission, requestPermission] = useCameraPermissions() const [photo, setPhoto] = useState('') const [address, setAddress] = useState('') const [notes, setNotes] = useState('') const cameraRef = useRef(null) async function resetState() { setPhoto('') setAddress('') setNotes('') } async function _takePhoto() { if (cameraRef.current) { let pic = await cameraRef.current.takePictureAsync({ quality: 0.1, base64: true }) console.log(pic) 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, address, notes }) }).then((res) => { console.log(res.status) if (res.status === 200) { resetState() } }) } 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