mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 04:45:17 +00:00
Add fetcher_helper for calendar and newsfeed
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
* MIT Licensed.
|
||||
*/
|
||||
const Log = require("logger");
|
||||
const FetcherHelper = require("fetcher_helper");
|
||||
const FeedMe = require("feedme");
|
||||
const fetch = require("node-fetch");
|
||||
const iconv = require("iconv-lite");
|
||||
@@ -84,12 +85,13 @@ const NewsfeedFetcher = function (url, reloadInterval, encoding, logFeedWarnings
|
||||
};
|
||||
|
||||
fetch(url, { headers: headers })
|
||||
.catch((error) => {
|
||||
fetchFailedCallback(this, error);
|
||||
scheduleTimer();
|
||||
.then(FetcherHelper.checkStatus)
|
||||
.then((response) => {
|
||||
response.body.pipe(iconv.decodeStream(encoding)).pipe(parser);
|
||||
})
|
||||
.then((res) => {
|
||||
res.body.pipe(iconv.decodeStream(encoding)).pipe(parser);
|
||||
.catch((error) => {
|
||||
fetchFailedCallback(this, error.message);
|
||||
scheduleTimer();
|
||||
});
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user