Probably fix HTTP 401
This commit is contained in:
parent
d19b9ced8f
commit
c428e4ab11
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user