$ npm install 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 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>
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
Stream or Blob as input body since they cannot be read or serialized synchronouslyFormData as input body yet as it has no built-in method to be serializedagent option as its value cannot be serializedtextConverted() method on SyncResponse and SyncRequestXMLHttpRequest is pretty limited. Supported are:
methodbodyheaderscredentials (but not omit)timeoutbuffer() and textConverted() methods are not supported© 2010 - cnpmjs.org x YWFE | Home | YWFE