Skip to content

Commit

Permalink
Patch out bug where no internet message does not display due to check…
Browse files Browse the repository at this point in the history
…ing res.ok when res is undefined due to try-catch
  • Loading branch information
malee31 committed Jan 15, 2024
1 parent a27b078 commit 2a2c6ac
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions components/parts/utils/serverClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ export async function verifyPassword(password) {
result.messages.push(`Unable to fetch status. Are you connected to the internet?`);
}

// TODO: Confirm that res.ok is false if fetch throws
if(res.ok) {
if(!res) {
// Do nothing if fetch errors. No internet message already added by catch ^ above.
} else if(res.ok) {
const jsonResponse = await res.json();
result.ok = true;
result.data.verified = true;
Expand Down Expand Up @@ -74,7 +75,9 @@ async function signInOut(password, signInMode) {
result.messages.push(`Unable to fetch status. Are you connected to the internet?`);
}

if(res.status === 400) {
if(!res) {
// Do nothing. No internet message already added by catch ^ above.
} else if(res.status === 400) {
result.ok = true;
result.messages.push(await res.text());
} else if(!res.ok) {
Expand Down

0 comments on commit 2a2c6ac

Please sign in to comment.