mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +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
|
||||
- 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
|
||||
|
||||
|
@ -9,6 +9,7 @@ const FeedMe = require("feedme");
|
||||
const NodeHelper = require("node_helper");
|
||||
const fetch = require("fetch");
|
||||
const iconv = require("iconv-lite");
|
||||
const stream = require("stream");
|
||||
|
||||
/**
|
||||
* 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 })
|
||||
.then(NodeHelper.checkFetchStatus)
|
||||
.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) => {
|
||||
fetchFailedCallback(this, error);
|
||||
|
Loading…
x
Reference in New Issue
Block a user