How to use the whatwg-fetch.Request function in whatwg-fetch

To help you get started, we’ve selected a few whatwg-fetch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github orangeloops / public-ol-native-template / config / jest / setup.js View on Github external
// Ensure environment variables are read.

const path = require("path");
const fs = require("fs-extra");
const dotenv = require("dotenv");

process.env = {
  ...process.env,
  ...dotenv.parse(fs.readFileSync(path.resolve(process.cwd(), ".env"))),
};

const fetchPolyfill = require("whatwg-fetch");

global.fetch = fetchPolyfill.fetch;
global.Request = fetchPolyfill.Request;
global.Headers = fetchPolyfill.Headers;
global.Response = fetchPolyfill.Response;

const axios = require("axios");
const httpAdapter = require("axios/lib/adapters/http");

axios.defaults.adapter = httpAdapter;

require("moment-timezone");
jest.doMock("moment", () => {
  const moment = jest.requireActual("moment");
  moment.tz.setDefault("America/New_York");
  return moment;
});

const mockAsyncStorage = require("@react-native-community/async-storage/jest/async-storage-mock");

whatwg-fetch

A window.fetch polyfill.

MIT
Latest version published 19 days ago

Package Health Score

97 / 100
Full package analysis