React Query set up for use (developers can use axios(preferred) or fetch to make a HTTP requests) so that developers can make async calls to get and modify data in our backend (in firebase) to be used for the frontend display
Created example Query Request to be used for GET requests
Created example Mutation Request to be used for POST, PUT, and DELETE requests
Added a date util function to standardize future API calls that need the date
How to Test
Start backend on local
Add EXPO_PUBLIC_IP_ADDR=<your ip addy> to your frontend .env
Add the SampleMutationRequest or SampleQueryRequest to a page and click the button to send a request
For example, since the friends page is unused currently, I added
import React from 'react';
import { SafeAreaView } from 'react-native';
import { Text, View } from 'tamagui';
import SampleQueryRequest from '../../components/SampleQueryRequest'
import SampleMutationRequest from '../../components/SampleMutationRequest'
const Friends = () => {
return (
<SafeAreaView>
<View>
<Text>Friends/search page</Text>
<SampleQueryRequest/>
<SampleMutationRequest/>
</View>
</SafeAreaView>
);
NOTE: the results are cached by react-query. If you are testing on android emulator, wipe your data if needed or you can invalidate the cache. If working on browser, open developer tools/inspect and right-click refresh button at top left, then click empty cache and hard reload
may also need to specify port number to ensure front and backend ports are the same
This closes #46
Description / Changes Made
axios
(preferred) orfetch
to make a HTTP requests) so that developers can make async calls to get and modify data in our backend (in firebase) to be used for the frontend displayHow to Test
EXPO_PUBLIC_IP_ADDR=<your ip addy>
to your frontend.env
SampleMutationRequest
orSampleQueryRequest
to a page and click the button to send a requestFor example, since the friends page is unused currently, I added
empty cache and hard reload
Portions of this code that utilized AI generation
Sample Pages
Mutation Example![image](https://github.com/UNLV-CS472-672/2024-S-GROUP5-Munch/assets/65695808/438619d0-6fc0-405e-adbd-26b477b95f3c)
Query Example![image](https://github.com/UNLV-CS472-672/2024-S-GROUP5-Munch/assets/65695808/cc5bddc4-519a-4357-b8aa-7156e14d9643)
Checklist