use internal fetch as replacement for node-fetch (#3184)

related to #2649

I was able to move to internal fetch and all tests seems fine so far.

But we have one problem with the calendar module. In the docs we have
several authentication methods and one of them is `digest`. For this we
used `digest-fetch` which needs `node-fetch` (this is not so clear from
code but I was not able to get it working).

So we have 3 options:
- remove `digest` as authentication method for calendar module (this is
what this PR does at the moment)
- find an alternative npm package or implement the digest stuff
ourselves
- use `digest-fetch` and `node-fetch` for calendar module (so they would
remain as dependencies in `package.json`)

Opinions? @KristjanESPERANTO @rejas @sdetweil @MichMich
This commit is contained in:
Karsten Hassel
2023-09-09 21:12:31 +02:00
committed by GitHub
parent ffdf321e23
commit f2957f90df
16 changed files with 24 additions and 115 deletions

View File

@@ -1,20 +0,0 @@
/**
* Helper class to provide either third party fetch library or (if node >= 18)
* return internal node fetch implementation.
*
* Attention: After some discussion we always return the third party
* implementation until the node implementation is stable and more tested
* @see https://github.com/MichMich/MagicMirror/pull/2952
* @see https://github.com/MichMich/MagicMirror/issues/2649
* @param {string} url to be fetched
* @param {object} options object e.g. for headers
* @class
*/
async function fetch(url, options = {}) {
// return global.fetch(url, options);
const nodefetch = require("node-fetch");
return nodefetch(url, options);
}
module.exports = fetch;

View File

@@ -1,7 +1,6 @@
const fs = require("fs");
const path = require("path");
const Log = require("logger");
const fetch = require("./fetch");
/**
* Gets the config.