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.

XMLHttpRequest is not defined

See original GitHub issue
  • Node Version: v7.5.0
  • Npm Version: 4.1.2
  • Platform: MacOS
  • Package Version: contentful v4.1.1

Running the code below in the node environment:

const contentfulClient = contentful.createClient({
    space, 
    accessToken: key
});

contentfulClient.getEntries({
    content_type: 'article',
    select: 'fields',
})
.catch(e => console.error(e))
.then(entries => {
    console.log(entries.items);
})

triggers the error:

ReferenceError: XMLHttpRequest is not defined
    at dispatchXhrRequest (/node_modules/contentful/dist/contentful.js:1671:23)

There are no other dependencies or transpilers. Just one file with the above-mentioned code.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Khaledgarbayacommented, Mar 30, 2017

Oh wow, for some reason axios thinks it is running in the browser, I will try to fix this asap. Sorry about that

1reaction
Khaledgarbayacommented, Mar 30, 2017

Thank a lot for the report @maximus8891 this is now fixed in https://github.com/contentful/contentful.js/pull/132 a new patch version will be out in few minutes

Read more comments on GitHub >

github_iconTop Results From Across the Web

XMLHttpRequest module not defined/found - Stack Overflow
XMLHttpRequest is a built-in object in web browsers. It is not distributed with Node. The http module is the built-in tool for making...
Read more >
Node.js - ReferenceError: XMLHttpRequest is not defined
Attempting to run the following JavaScript code (an AJAX call using XMLHttpRequest) throws a ReferenceError under Node, but works in a web browser....
Read more >
XMLHttpRequest is not defined - Replit
trying to create a new XMLHttpRequest object but the console shows: ReferenceError: XMLHttpRequest is not defined at /home/runner/ajax/index.js:1:17
Read more >
ReferenceError: XMLHttpRequest is not defined #15040
Hi all,. I'm trying to connect to the Solana blockchain via a Deno http server. This is my code: import { serve }...
Read more >
Getting ReferenceError: XMLHttpRequest is not defined
When I am trying to authenticate client using Javascript SDK I am getting the above ReferenceError: XMLHttpRequest is not defined.
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