sync-fetch
Synchronous version of the Fetch API
Last updated 2 months ago by larsgw .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install sync-fetch 
SYNC missed versions from official npm registry.

sync-fetch

Synchronous wrapper around the Fetch API. Uses node-fetch. For a package using version of fetch built into Node.js, see sync-fetch-undici.

npm npm monthly downloads

Install

npm install sync-fetch

In the browser, a browserify bundle can be loaded from CDNs like unpkg.com.

<script src="https://unpkg.com/sync-fetch"></script>
<script src="https://unpkg.com/sync-fetch@VERSION"></script>

Use

const fetch = require('sync-fetch')

const metadata = fetch('https://doi.org/10.7717/peerj-cs.214', {
  headers: {
    Accept: 'application/vnd.citationstyles.csl+json'
  }
}).json()
// arrayBuffer(), blob(), buffer(), json(), and text() supported

Limitations

Node.js

  • Does not support Stream or Blob as input body since they cannot be read or serialized synchronously
  • Does not support FormData as input body yet as it can contain a Blob
  • Does not support signal as it cannot be implemented synchronously
  • Does not support the non-spec agent option as its value cannot be serialized
  • Does not support non-standard textConverted() method on SyncResponse and SyncRequest

Browser

  • Does not support most options, since XMLHttpRequest is pretty limited. Supported are:
    • method
    • body
    • headers
    • credentials (but not omit)
    • (Non-spec) timeout
  • The non-standard buffer() and textConverted() methods are not supported
  • CORS limitations apply, of course (note they may be stricter for synchronous requests)

Current Tags

  • 0.7.1                                ...           latest (2 months ago)

21 Versions

  • 0.7.1                                ...           2 months ago
  • 0.7.0                                ...           2 months ago
  • 0.6.0                                ...           a year ago
  • 0.6.0-2                                ...           2 years ago
  • 0.6.0-1                                ...           2 years ago
  • 0.6.0-0                                ...           2 years ago
  • 0.5.2                                ...           3 years ago
  • 0.5.1                                ...           3 years ago
  • 0.5.0                                ...           3 years ago
  • 0.4.5                                ...           3 years ago
  • 0.4.4                                ...           3 years ago
  • 0.4.3                                ...           3 years ago
  • 0.4.2                                ...           4 years ago
  • 0.4.1                                ...           5 years ago
  • 0.4.0                                ...           5 years ago
  • 0.3.1                                ...           5 years ago
  • 0.3.0                                ...           6 years ago
  • 0.2.1                                ...           6 years ago
  • 0.2.0                                ...           6 years ago
  • 0.1.1                                ...           7 years ago
  • 0.1.0                                ...           7 years ago
Maintainers (1)
Downloads
Total 104
Today 0
This Week 5
This Month 45
Last Day 1
Last Week 5
Last Month 43
Dependencies (3)
Dev Dependencies (13)

© 2010 - cnpmjs.org x YWFE | Home | YWFE