Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@plasmicapp/isomorphic-unfetch

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@plasmicapp/isomorphic-unfetch

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

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Isomorphic Unfetch

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

Fork differences:

  1. On Node, node-fetch is always used instead of global.fetch. This is a workaround this undici bug which is negatively affecting many versions of Node and Next.js.
  2. Don't polyfill, leave global.fetch alone.
  3. Applies a patch on node-fetch-cjs to this node-fetch bug by following this PR. Then we inline node-fetch-cjs into the built version of server.js, so that it will contain our patched version of node-fetch-cjs.

Install

This project uses node and npm. Go check them out if you don't have them locally installed.

$ npm i isomorphic-unfetch

Then with a module bundler like rollup or webpack, use as you would anything else:

// using ES6 modules
import fetch from 'isomorphic-unfetch'

// using CommonJS modules
const fetch = require('isomorphic-unfetch')

Usage

As a ponyfill:

import fetch from 'isomorphic-unfetch';

fetch('/foo.json')
  .then( r => r.json() )
  .then( data => {
    console.log(data);
  });

Globally, as a polyfill:

import 'isomorphic-unfetch';

// "fetch" is now installed globally if it wasn't already available

fetch('/foo.json')
  .then( r => r.json() )
  .then( data => {
    console.log(data);
  });

License

MIT License © Jason Miller

FAQs

Package last updated on 30 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc