@js-bits/fetch
TypeScript icon, indicating that this package has built-in type declarations

3.1.4 • Public • Published

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.

Installation

Install with npm:

npm install @js-bits/fetch

Install with yarn:

yarn add @js-bits/fetch

Import where you need it:

import fetch from '@js-bits/fetch';

or require for CommonJS:

const fetch = require('@js-bits/fetch');

How to use

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

Notes

/@js-bits/fetch/

    Package Sidebar

    Install

    npm i @js-bits/fetch

    Weekly Downloads

    53

    Version

    3.1.4

    License

    ISC

    Unpacked Size

    6.24 kB

    Total Files

    13

    Last publish

    Collaborators

    • apolo-gh