Skip to content

Commit

Permalink
chore: add handled promise rejections
Browse files Browse the repository at this point in the history
  • Loading branch information
hopetambala committed Nov 24, 2020
1 parent 174320d commit 2dd2b56
Showing 1 changed file with 3 additions and 34 deletions.
37 changes: 3 additions & 34 deletions modules/geolocation/index.js
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 2dd2b56

Please sign in to comment.