mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
snapshot
This commit is contained in:
@@ -44,9 +44,10 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
const fetchCalendar = function () {
|
const fetchCalendar = function () {
|
||||||
clearTimeout(reloadTimer);
|
clearTimeout(reloadTimer);
|
||||||
reloadTimer = null;
|
reloadTimer = null;
|
||||||
httpsAgent = null;
|
let httpsAgent = null;
|
||||||
user = "";
|
let user = "";
|
||||||
password = "";
|
let password = "";
|
||||||
|
let opts = {};
|
||||||
|
|
||||||
const nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
|
const nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
|
||||||
const headers = {
|
const headers = {
|
||||||
@@ -59,7 +60,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: auth,
|
// todo: bearer
|
||||||
// https://github.com/devfans/digest-fetch
|
// https://github.com/devfans/digest-fetch
|
||||||
// https://github.com/pablopunk/auth-fetch/blob/master/index.js
|
// https://github.com/pablopunk/auth-fetch/blob/master/index.js
|
||||||
// https://hackersandslackers.com/making-api-requests-with-nodejs/
|
// https://hackersandslackers.com/making-api-requests-with-nodejs/
|
||||||
@@ -71,11 +72,13 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
} else {
|
} else {
|
||||||
user = auth.user;
|
user = auth.user;
|
||||||
password = auth.pass;
|
password = auth.pass;
|
||||||
|
if (auth.method === "basic") {
|
||||||
|
opts = { basic: true };
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const client = new fetch(user, password);
|
new fetch(user, password, opts)
|
||||||
client
|
|
||||||
.fetch(url, { headers: headers, httpsAgent: httpsAgent })
|
.fetch(url, { headers: headers, httpsAgent: httpsAgent })
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
fetchFailedCallback(self, error);
|
fetchFailedCallback(self, error);
|
||||||
|
Reference in New Issue
Block a user