TypeError: Headers is not a constructor
See original GitHub issueI’ve had a somewhat frustrating start to ky, not sure what I’m doing wrong
(node:29176) UnhandledPromiseRejectionWarning: TypeError: Headers is not a constructor
at new Ky (/Volumes/Repositories/Private/apitests/testProj1/node_modules/ky/umd.js:211:20)
at Function.ky.(anonymous function) [as get] (/Volumes/Repositories/Private/apitests/testProj1/node_modules/ky/umd.js:389:37)
at getParentChildEndpoint (/Volumes/Repositories/Private/apitests/testProj1/src/api/util/getParentChildEndpoint.js:14:16)
at Object.getStatus (/Volumes/Repositories/Private/apitests/testProj1/src/api/instanceApi.js:49:22)
Rerproduced like this:
const ky = require('ky-universal').default;
const prefix = 'http://aa9da6ff.ngrok.io/api/instances/gub6r';
const instanceApi = ky.create({ prefixUrl: prefix, throwHttpErrors: false });
const result = await instanceApi.get('status').json();
This seems to be line 211 in umd.js:
I have both KY and Ky-universal installed. What am I doing wrong or missing?
If I try to catch this, the error is the same as that shown in the stack trace. I’d expect a HTTP error (like 404), not a stack trace like this. Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:21 (1 by maintainers)
Top Results From Across the Web
Node-express : fetch.Header() is not a constructor
But the main problem I am facing is with the Headers in new version, it throws error fetch.Headers() is not a constructor, although...
Read more >TypeError: "x" is not a constructor - JavaScript - MDN Web Docs
The JavaScript exception "is not a constructor" occurs when there was an attempt to use an object or a variable as a constructor,...
Read more >TypeError: Headers is not a constructor #7 - Issuehunt
I have both KY and Ky-universal installed. What am I doing wrong or missing? If I try to catch this, the error is...
Read more >How to use the node-fetch.Headers function in node-fetch | Snyk
To help you get started, we've selected a few node-fetch.Headers examples, based on popular ways it is used in public projects.
Read more >Class extends value #<Object> is not a constructor or null
TypeError - Class extends value #<Object> is not a constructor or null ... but passing a body parameter fails with GET headers: {...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If it helps, I’ve a simple test case for this @ https://github.com/markwoon/ky-universal-jest
Just run:
@szmarczak Or we can just check each global individually?