0.5.2 • Published 2 years ago

sync-fetch v0.5.2

Weekly downloads
826,330
License
MIT
Repository
github
Last release
2 years 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-2866synvert-coresymeo-jstailwind-highlightjstele-bot-apistrapi-plugin-file-select@driffel/universal-google-logger@peaceroad/markdown-it-renderer-imagelcd-router-webpack-plugingothic-sexytoken@sfdocs-internal/sfdocs-directive-plugininsaneazkastubber-interpolation-pkgstustorgnodesradsrequest_jstwitter-urltrackle-library-nodejstofulangturbotracer@applitools/sdk-coverage-tests@asiz33/smartblok-vendure-plugin@asyncapi/html-template@astrolabs/hardhat@citation-js/coreyao-node-clientzuixwealth8-api-explorer-expresswebql-tools-url-loader@fedikit/remark-webfinger-mentions@easy-push/ts-client@hedgehogcomputing/core@kottster/cli@linx-digital/design-token-transformer@microsoft/jest-sarif@nandenjin/mrm-preset@eryandia/react-bbt-sso-client@microsoft/sarif-matcher-utils@mliebelt/pgn-reader@morajlab-website/utilities@onlinemad/markdown-it-link-preview@poriyaalar/react-pdf-html@phala/index@plurid/datasign@plurid/deon@p-lang/plang@solace-community/stmmuse-jrjraunarutouzumacinuxt-openapi-docs-modulepandemicsscrapple-libserenade.devtoolsnode-fluent-ytdlpnocaptchasolverplugin-node-patternlab-inline-remote-assetsphersentrepldbinfos-discordhomebridge-solaxcloud-apiinsanytzhomebridge-assistant-uileak-simulatormarkdown-it-image-sizemarkdown-it-inline-plantumlmedusa-plugin-customsearchreaction-cli@xarber/xshopjs@synvert-hq/synvert-core@tonice/core@thedave42/f1tv-namer@yotamloe/instrumentation-user-interaction@subsquid/archive-registry@tagspaces/tagspaces-common-electronadacli-jsadonis-testbabel-plugin-yxbj-iconapitoolkit-adonis-sixapitoolkit-adonis-v6cardanocli-js-lambdachatcola-servercdk-v1-construct-simple-natcdk-construct-simple-natcodeconnectioncool-picsdeinflationbetter-codeblockdiscord.js-tokendevtooliumdonedeal_search_apidx-coreeryandia.react-bbt-sso-client
0.4.5

2 years ago

0.4.4

2 years ago

0.5.0

2 years ago

0.5.2

2 years ago

0.4.3

2 years ago

0.5.1

2 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.1

4 years ago

0.3.0

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.1

6 years ago

0.1.0

6 years ago