From 2dd2b5675893a51478e22b00dccfec47834fd5c8 Mon Sep 17 00:00:00 2001 From: Hope Tambala Date: Mon, 23 Nov 2020 23:59:51 -0500 Subject: [PATCH] chore: add handled promise rejections --- modules/geolocation/index.js | 37 +++--------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) diff --git a/modules/geolocation/index.js b/modules/geolocation/index.js index 37517b2bd..b3306ca19 100644 --- a/modules/geolocation/index.js +++ b/modules/geolocation/index.js @@ -1,42 +1,11 @@ import * as Location from 'expo-location'; export default async function getLocation() { - const { status } = await Location.requestPermissionsAsync(); + const { status } = await Location.requestPermissionsAsync().catch((err) => console.log(err)); //eslint-disable-line if (status !== 'granted') { return 'Permission to access location was denied'; } - const currentLocation = await Location.getCurrentPositionAsync({}); + const currentLocation = await Location.getCurrentPositionAsync({}).catch((err) => console.log(err)); //eslint-disable-line return currentLocation; -} -// import * as React from 'react'; -// import * as Location from 'expo-location'; - -// const getLocation = () => { -// const [location, setLocation] = React.useState(null); -// const [errorMsg, setErrorMsg] = React.useState(null); - -// React.useEffect(() => { -// (async () => { -// const { status } = await Location.requestPermissionsAsync(); -// if (status !== 'granted') { -// setErrorMsg('Permission to access location was denied'); -// } - -// const currentLocation = await Location.getCurrentPositionAsync({}); -// setLocation(currentLocation); -// })(); -// }); - -// let text = 'Waiting..'; - -// if (errorMsg) { -// text = errorMsg; -// } else if (location) { -// text = JSON.stringify(location); -// } - -// return text; -// }; - -// export default getLocation; +} \ No newline at end of file