MagicMirror/js/fetch.js
Kristjan ESPERANTO 7c64d8fce6
Minimum node version v18 (#3170)
When the next MagicMirror version is released, node v16 will have
reached its end of life.
2023-08-20 12:55:17 +02:00

21 lines
679 B
JavaScript

/**
* 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;