node-csfd-api
Version:
ČSFD API in JavaScript. Amazing NPM library for scrapping csfd.cz :)
10 lines (9 loc) • 581 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchSafe = void 0;
// Check if `fetch` is available in global scope (nodejs 18+) or in window (browser). If not, use cross-fetch polyfill.
const cross_fetch_1 = require("cross-fetch");
exports.fetchSafe = (typeof fetch === 'function' && fetch) || // ServiceWorker fetch (Cloud Functions + Chrome extension)
(typeof global === 'object' && global.fetch) || // Node.js 18+ fetch
(typeof window !== 'undefined' && window.fetch) || // Browser fetch
cross_fetch_1.fetch; // Polyfill fetch
;