How to use the isomorphic-unfetch.Request function in isomorphic-unfetch

To help you get started, we’ve selected a few isomorphic-unfetch 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 strues / boldr / packages / core / src / server.js View on Github external
// Polyfill for fetch() API in NodeJS based on code from
// https://github.com/matthew-andrews/isomorphic-fetch/blob/master/fetch-npm-node.js
if (!global.fetch) {
  const realFetch = require('isomorphic-unfetch');
  global.fetch = function fetch(url, options) {
    const normalized = /^\/\//.test(url) ? `https:${url}` : url;
    return realFetch.call(this, normalized, options);
  };
  global.Response = realFetch.Response;
  global.Headers = realFetch.Headers;
  global.Request = realFetch.Request;
}

export { default as serverRender } from './server/serverRender';
export * from './common';

isomorphic-unfetch

Switches between unfetch & node-fetch for client & server.

MIT
Latest version published 2 years ago

Package Health Score

73 / 100
Full package analysis