Package Exports
- @ardatan/sync-fetch
- @ardatan/sync-fetch/browser.js
- @ardatan/sync-fetch/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ardatan/sync-fetch) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
sync-fetch
Synchronous wrapper around the Fetch API. Uses node-fetch under the hood, and for some input-parsing code and test cases too.
Install
npm install sync-fetchUse
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() supportedLimitations
Node.js
- Does not support
Streams (orFormData) 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
agentoption as its value cannot be serialized
Browser
- Does not support most options, since
XMLHttpRequestis pretty limited. Supported are:methodbodyheaderscredentials(but notomit)- (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)