-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add handled promise rejections
- Loading branch information
1 parent
174320d
commit 2dd2b56
Showing
1 changed file
with
3 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |