pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/larsgw/sync-fetch

nonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-a33d805aa3bce2cb.css" /> GitHub - larsgw/sync-fetch: Synchronous wrapper around the Fetch API · GitHub
Skip to content

larsgw/sync-fetch

Repository files navigation

sync-fetch

Synchronous wrapper around the Fetch API. Uses node-fetch under the hood, and for some input-parsing code and test cases too.

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 has no built-in method to be serialized
  • 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)

About

Synchronous wrapper around the Fetch API

Resources

License

Stars

Watchers

Forks

Contributors

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy