Skip to content
This repository has been archived by the owner on Jun 12, 2022. It is now read-only.

Error when first argument is a Request instance #56

Open
xzyfer opened this issue May 29, 2018 · 0 comments
Open

Error when first argument is a Request instance #56

xzyfer opened this issue May 29, 2018 · 0 comments

Comments

@xzyfer
Copy link

xzyfer commented May 29, 2018

The documentation states

fetch(uriOrRequest, [opts]) -> Promise

However using a Request instance results in an error.

➜ node
> const fetch = require('make-fetch-happen');
undefined
> const Request = require('node-fetch').Request;
undefined
> fetch(new Request('https://google.com')).then(console.log)
TypeError: Parameter "url" must be a string, not object
    at Url.parse (url.js:102:11)
    at Object.urlParse [as parse] (url.js:96:13)
    at getProxyUri (/Users/michaelmifsud/src/shop/app/node_modules/make-fetch-happen/agent.js:116:24)
    at getAgent (/Users/michaelmifsud/src/shop/app/node_modules/make-fetch-happen/agent.js:14:17)
    at remoteFetch (/Users/michaelmifsud/src/shop/app/node_modules/make-fetch-happen/index.js:310:17)
    at cachingFetch (/Users/michaelmifsud/src/shop/app/node_modules/make-fetch-happen/index.js:176:10)
    at repl:1:1
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at REPLServer.defaultEval (repl.js:239:29)
    at bound (domain.js:301:14)

From a glance at the code the first parameter to fetch is generally assumed to be a string.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant