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.

Headers is not defined

See original GitHub issue

I instruct Zombie to visit a page which has the following code:

fetch('http://localhost:8000/', {
    body: body,
    method: 'post',
    headers: new Headers({ 'Content-Type': 'text/plain' })
}).then(function (res) {return true; });

Then I get an error that Headers is not defined, so the script within the simulated headless browser does not continue because it does not recognize Headers. Do I need to add some option to Zombie so it recognizes the entire standard JS Fetch API?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
edclementcommented, Jan 12, 2019

You’re running within the context of node, not the browser. You can polyfill the Headers class from the browser: https://www.npmjs.com/package/fetch-headers

You’re better off just using a vanilla object though…

0reactions
ozyman42commented, Jan 13, 2019

I’d be more than happy to submit a PR that adds the polyfills.

Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs - 'ReferenceError: Headers is not defined' when using ...
I'm setting up a new application in React and I want it to be server side rendered. Unfortunately I'm not able to use...
Read more >
javascript api call - Headers is not defined - LinuxQuestions.org
Any (competent) library which sends HTTP requests has a means to set the headers - you just need to check the docs for...
Read more >
ReferenceError: Headers is not defined · Issue #56 - GitHub
When using swiftype-app-search-javascript to do search in an app using coffee script, I got Headers is not defined error.
Read more >
Headers is not defined' when using Headers in a server side ...
Coding example for the question 'ReferenceError: Headers is not defined' when using Headers in a server side rendered react project-Reactjs.
Read more >
Headers not found - Coding Help - Glitch Support
I use for that the “fetch” JS function with some Headers. My problem is the following : Glitch ... ReferenceError: Headers is not...
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