untitled notebook

node v10.24.1
version: master
endpointsharetweet
const got = require('got'); const http = require('http'); const https = require('https'); const urlToOptions = require('got/dist/source/utils/url-to-options').default; const instance = got.extend({ request: (url, options, callback) => { if (url.protocol === 'https:') { return https.request({...options, ...urlToOptions(url)}, callback); } return http.request({...options, ...urlToOptions(url)}, callback); } }); (async () => { const body = await instance('https://httpbin.org/anything').json(); console.log(body); })();
Loading…

no comments

    sign in to comment