Skip to content
Snippets Groups Projects
Commit 840bf229 authored by Mikkel Aas's avatar Mikkel Aas
Browse files

added alert message when there is an error

parent b27c20bf
No related branches found
No related tags found
1 merge request!87Update fetch calls
......@@ -17,19 +17,18 @@ export default function StateUserLoginView({navigation}: any): JSX.Element {
// fetch person data from the database
const getPersonData = async () => {
try {
const rawdata = await fetch(STATE_PERSON_URL + text);
const json = await rawdata.json();
const response = await fetch(STATE_PERSON_URL + text);
const json = await response.json();
if (rawdata.status === 200) {
if (response.ok) {
navigation.navigate('StateUserPage', {
item: json
});
return;
}
setInvalid(true);
} catch (error) {
alert('Something went wrong, please try again later.');
console.error(error);
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment