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

@js-bits/fetch

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@js-bits/fetch

Cross-environment (nodejs/web) fetch API

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-95.77%
Maintainers
1
Weekly downloads
 
Created
Source

Cross-environment (nodejs/web) fetch APi

This package exports window.fetch object in a browser and node-fetch module in a Node.js environment. Which is helpful when you develop a package compatible with both environments and use fetch for HTTP requests. Allows to avoid conditional imports.

Also exports AbortController (abort-controller module for Node.js) for both environments.

Installation

Install with npm:

npm install @js-bits/fetch

Install with yarn:

yarn add @js-bits/fetch

Import where you need it:

import { fetch, AbortController } from '@js-bits/fetch';

or require for CommonJS:

const { fetch, AbortController } = require('@js-bits/fetch');

How to use

fetch('http://example.com/movies.json')
  .then(response => response.json())
  .then(data => console.log(data));

Notes

  • v2 of this package supports v2 of node-fetch
  • Minimal size (bytes) in a browser since Fetch API is natively supported. Does not include any polyfills, which means that Internet Explorer is not supported.

Keywords

FAQs

Package last updated on 27 Mar 2022

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