UNPKG

624 BJavaScriptView Raw
1const nodeFetch = require('node-fetch')
2const realFetch = nodeFetch.default || nodeFetch
3
4const fetch = function (url, options) {
5 // Support schemaless URIs on the server for parity with the browser.
6 // Ex: //github.com/ -> https://github.com/
7 if (/^\/\//.test(url)) {
8 url = 'https:' + url
9 }
10 return realFetch.call(this, url, options)
11}
12
13fetch.ponyfill = true
14
15module.exports = exports = fetch
16exports.fetch = fetch
17exports.Headers = nodeFetch.Headers
18exports.Request = nodeFetch.Request
19exports.Response = nodeFetch.Response
20
21// Needed for TypeScript consumers without esModuleInterop.
22exports.default = fetch