question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Headers is not a constructor

See original GitHub issue

I’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: Screenshot 2019-06-17 at 11 15 57

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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:21 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
markwooncommented, Jul 15, 2021

If it helps, I’ve a simple test case for this @ https://github.com/markwoon/ky-universal-jest

Just run:

# yarn build
# node dist/main.bundle.js
1reaction
sindresorhuscommented, Jul 5, 2019

@szmarczak Or we can just check each global individually?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found