mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 04:02:12 +00:00
fix newsfeedfetcher using correct stream version (changed with node-18-fetch)
This commit is contained in:
parent
4f1db749c0
commit
591f907134
@ -19,7 +19,7 @@ _This release is scheduled to be released on 2022-07-01._
|
|||||||
|
|
||||||
- Use latest node 18 when running tests on github actions
|
- Use latest node 18 when running tests on github actions
|
||||||
- Update `electron` to v19 and other dependencies.
|
- Update `electron` to v19 and other dependencies.
|
||||||
- Use internal fetch function of node instead external `node-fetch` library if node version >= `v18`.
|
- Use internal fetch function of node instead external `node-fetch` library if used node version >= `v18`.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ const FeedMe = require("feedme");
|
|||||||
const NodeHelper = require("node_helper");
|
const NodeHelper = require("node_helper");
|
||||||
const fetch = require("fetch");
|
const fetch = require("fetch");
|
||||||
const iconv = require("iconv-lite");
|
const iconv = require("iconv-lite");
|
||||||
|
const stream = require("stream");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responsible for requesting an update on the set interval and broadcasting the data.
|
* Responsible for requesting an update on the set interval and broadcasting the data.
|
||||||
@ -87,7 +88,13 @@ const NewsfeedFetcher = function (url, reloadInterval, encoding, logFeedWarnings
|
|||||||
fetch(url, { headers: headers })
|
fetch(url, { headers: headers })
|
||||||
.then(NodeHelper.checkFetchStatus)
|
.then(NodeHelper.checkFetchStatus)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
response.body.pipe(iconv.decodeStream(encoding)).pipe(parser);
|
let nodeStream;
|
||||||
|
if (response.body instanceof stream.Readable) {
|
||||||
|
nodeStream = response.body;
|
||||||
|
} else {
|
||||||
|
nodeStream = stream.Readable.fromWeb(response.body);
|
||||||
|
}
|
||||||
|
nodeStream.pipe(iconv.decodeStream(encoding)).pipe(parser);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
fetchFailedCallback(this, error);
|
fetchFailedCallback(this, error);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user