From c428e4ab110582e61a7b08b08ca0aad1df92aab9 Mon Sep 17 00:00:00 2001 From: Maks Snegov Date: Fri, 26 Apr 2024 23:45:56 -0700 Subject: [PATCH] Probably fix HTTP 401 --- scripts/content.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/content.js b/scripts/content.js index d2230c9..ce0998a 100644 --- a/scripts/content.js +++ b/scripts/content.js @@ -129,10 +129,8 @@ async function handleHttpError(e) { console.log(msg); await sendNotification(msg); await logOut(); - return null; } else { console.error(e); - return null; } } @@ -211,12 +209,16 @@ async function getAvailableDates(consulateId) { let uri = window.location.pathname + `/days/${consulateId}.json?appointments[expedite]=false` let dates = fetch(uri, { headers: { "x-requested-with": "XMLHttpRequest" }}) .then(d => d.json()) + .catch(async e => { + await handleHttpError(e); + throw e; + }) .then(data => { let dateList = data.map(item => item.date); dateList.sort(); return dateList; }) - .catch(async e => handleHttpError(e)); + .catch(e => null); return dates; } @@ -234,8 +236,12 @@ async function getAvailableTimes(consulateId, date) { let uri = window.location.pathname + `/times/${consulateId}.json?date=${date}&appointments[expedite]=false` let times = await fetch(uri, { headers: { "x-requested-with": "XMLHttpRequest" } }) .then(d => d.json()) + .catch(async e => { + await handleHttpError(e); + throw e; + }) .then(data => data.available_times) - .catch(e => handleHttpError(e)); + .catch(e => null); return times; }