Files
address-verification-app/src/hooks/capturingApi.ts
2023-08-02 19:01:20 +05:30

40 lines
1.0 KiB
TypeScript

import { type GeoCoordinates } from 'react-native-geolocation-service';
import axiosInstance, { ApiKeys, getApiUrl } from '../components/utlis/apiHelper';
export const sendLocationAndActivenessToServer = async (
location: GeoCoordinates,
isActive: boolean
) => {
try {
const response = await axiosInstance.post(
getApiUrl(ApiKeys.SEND_LOCATION),
[
{
latitude: location?.latitude,
longitude: location?.longitude,
accuracy: location?.accuracy,
timestamp: new Date().getTime(),
isActiveOnApp: isActive,
},
],
{
headers: {
donotHandleError: 'true',
},
}
);
} catch (error) {
console.log(error);
}
};
export const getSyncTime = async () => {
try {
const url = getApiUrl(ApiKeys.SYNC_TIME);
const response = await axiosInstance.get(url, { headers: { donotHandleError: true } });
return response?.data?.currentTimestamp;
} catch (error) {
console.log(error);
}
};