This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
admin-panel/graphql-types/node_modules/sync-fetch
2021-03-09 19:44:13 +01:00
..
browser.js add configured graphql-codegen 2021-03-09 19:44:13 +01:00
bundle.js add configured graphql-codegen 2021-03-09 19:44:13 +01:00
index.js add configured graphql-codegen 2021-03-09 19:44:13 +01:00
LICENSE add configured graphql-codegen 2021-03-09 19:44:13 +01:00
package.json add configured graphql-codegen 2021-03-09 19:44:13 +01:00
README.md add configured graphql-codegen 2021-03-09 19:44:13 +01:00
shared.js add configured graphql-codegen 2021-03-09 19:44:13 +01:00
worker.js add configured graphql-codegen 2021-03-09 19:44:13 +01:00

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

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()

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
  • Does not support binary responses in the main thread
  • CORS limitations apply, of course (note they may be stricter for synchronous requests)