0.5.2 • Published 11 months ago

sync-fetch v0.5.2

Weekly downloads
826,330
License
MIT
Repository
github
Last release
11 months ago

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

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()
// json(), arrayBuffer(), text() and buffer() supported

Limitations

Node.js

  • Does not support Streams (or FormData) as input bodies since they cannot be read or serialized synchronously
  • Does not support Blobs as input bodies since they're too complex
  • Does not support the non-spec agent option as its value cannot be serialized

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() method is not supported
  • CORS limitations apply, of course (note they may be stricter for synchronous requests)
hxfhoafjvlwcawecwrsurvihogpqqkaqvlmhywdpzasrhssfcgmoo4nfindmoonfindsvfeirtvgpdaghemujiuokble@infinitebrahmanuniverse/nolb-sync@prodam/prodam-typespredictive-sentence-generator@everything-registry/sub-chunk-2866infos-discordhomebridge-assistant-uiinsanytzinsaneazkagatsby-source-lbry@fedikit/remark-webfinger-mentions@easy-push/ts-clienthomebridge-solaxcloud-apigothic-sexytoken@sfdocs-internal/sfdocs-directive-plugin@shelex/parallel-specs-client@shelex/split-specs-clientpandemics@p-lang/plangphersentnode-fluent-ytdlp@poriyaalar/react-pdf-htmlnocaptchasolvernuxt-openapi-docs-module@subsquid/archive-registryplugin-node-patternlab-inline-remote-assets@linx-digital/design-token-transformerleak-simulatorlcd-router-webpack-pluginmarkdown-it-image-sizemarkdown-it-inline-plantuml@nandenjin/mrm-presetmedusa-plugin-customsearch@onlinemad/markdown-it-link-preview@phala/index@peaceroad/markdown-it-renderer-image@plurid/datasign@plurid/deon@tonice/core@synvert-hq/synvert-core@tagspaces/tagspaces-common-electron@thedave42/f1tv-namer@asyncapi/html-template@asiz33/smartblok-vendure-plugintele-bot-api@applitools/sdk-coverage-testschatcola-servercdk-construct-simple-natsymeo-jstailwind-highlightjssynvert-corecardanocli-jscardanocli-js-lambdacdk-v1-construct-simple-natstustorgnodestrapi-plugin-file-selectstubber-interpolation-pkgcodeconnectioncool-picstofulang@citation-js/corebetter-codeblockapitoolkit-expressapitoolkit-fastifyapitoolkit-adonisserenade.devtoolsscrapple-libadonis-testbabel-plugin-yxbj-iconsrequest_jssrad@yotamloe/instrumentation-user-interactionreaction-cli@xarber/xshopjsrepldbadacli-jsturbotracertwitter-urldiscord.js-tokendeinflationdevtooliumdonedeal_search_apiwealth8-api-explorer-express@driffel/universal-google-loggerwebql-tools-url-loaderyao-node-clientzuix@microsoft/jest-sarif@microsoft/sarif-matcher-utils@mliebelt/pgn-reader@morajlab-website/utilities@hedgehogcomputing/core
0.4.5

11 months ago

0.4.4

11 months ago

0.5.0

11 months ago

0.5.2

11 months ago

0.4.3

11 months ago

0.5.1

11 months ago

0.4.2

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.1

3 years ago

0.2.0

4 years ago

0.1.1

5 years ago

0.1.0

5 years ago