mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 12:12:20 +00:00
removed getFetcher function
This commit is contained in:
parent
fa0f997928
commit
514b9453f8
@ -44,12 +44,14 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
* Initiates calendar fetch.
|
* Initiates calendar fetch.
|
||||||
*/
|
*/
|
||||||
const fetchCalendar = function () {
|
const fetchCalendar = function () {
|
||||||
function getFetcher(url, auth) {
|
clearTimeout(reloadTimer);
|
||||||
|
reloadTimer = null;
|
||||||
const nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
|
const nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
|
||||||
|
let fetcher = null;
|
||||||
|
let httpsAgent = null;
|
||||||
let headers = {
|
let headers = {
|
||||||
"User-Agent": "Mozilla/5.0 (Node.js " + nodeVersion + ") MagicMirror/" + global.version + " (https://github.com/MichMich/MagicMirror/)"
|
"User-Agent": "Mozilla/5.0 (Node.js " + nodeVersion + ") MagicMirror/" + global.version + " (https://github.com/MichMich/MagicMirror/)"
|
||||||
};
|
};
|
||||||
let httpsAgent = null;
|
|
||||||
|
|
||||||
if (selfSignedCert) {
|
if (selfSignedCert) {
|
||||||
httpsAgent = new https.Agent({
|
httpsAgent = new https.Agent({
|
||||||
@ -60,17 +62,16 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
if (auth.method === "bearer") {
|
if (auth.method === "bearer") {
|
||||||
headers.Authorization = "Bearer " + auth.pass;
|
headers.Authorization = "Bearer " + auth.pass;
|
||||||
} else if (auth.method === "digest") {
|
} else if (auth.method === "digest") {
|
||||||
return new digest(auth.user, auth.pass).fetch(url, { headers: headers, httpsAgent: httpsAgent });
|
fetcher = new digest(auth.user, auth.pass).fetch(url, { headers: headers, httpsAgent: httpsAgent });
|
||||||
} else {
|
} else {
|
||||||
headers.Authorization = "Basic " + base64.encode(auth.user + ":" + auth.pass);
|
headers.Authorization = "Basic " + base64.encode(auth.user + ":" + auth.pass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fetch(url, { headers: headers, httpsAgent: httpsAgent });
|
if (fetcher === null) {
|
||||||
|
fetcher = fetch(url, { headers: headers, httpsAgent: httpsAgent });
|
||||||
}
|
}
|
||||||
clearTimeout(reloadTimer);
|
|
||||||
reloadTimer = null;
|
|
||||||
|
|
||||||
getFetcher(url, auth)
|
fetcher
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
fetchFailedCallback(self, error);
|
fetchFailedCallback(self, error);
|
||||||
scheduleTimer();
|
scheduleTimer();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user