★ wanayoo — archive 1999 https://github.com/developit/unfetch/issues/146Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XMLHttpRequest is not defined #146

Open
DennisMamedov opened this issue Nov 30, 2020 · 0 comments
Open

XMLHttpRequest is not defined #146

DennisMamedov opened this issue Nov 30, 2020 · 0 comments

Comments

@DennisMamedov
Copy link

@DennisMamedov DennisMamedov commented Nov 30, 2020

Hello, I'm using Next.JS for a project. when using unfetch I get this weird error.

import fetch from 'unfetch'
...
await fetch(`/api/...`).then(res => { ... }

This piece of code errors

ReferenceError: XMLHttpRequest is not defined
    at C:\static\st-client\node_modules\unfetch\dist\unfetch.js:1:77
    at new Promise (<anonymous>)
    at module.exports (C:\static\st-client\node_modules\unfetch\dist\unfetch.js:1:45)
    at getServerSideProps (C:\static\st-client\.next\server\pages\games.js:4214:55)
    at renderToHTML (C:\static\st-client\node_modules\next\dist\next-server\server\render.js:39:221)
    at async C:\static\st-client\node_modules\next\dist\next-server\server\next-server.js:98:97
    at async C:\static\st-client\node_modules\next\dist\next-server\server\next-server.js:91:142
    at async DevServer.renderToHTMLWithComponents (C:\static\st-client\node_modules\next\dist\next-server\server\next-server.js:123:387)
    at async DevServer.renderToHTML (C:\static\st-client\node_modules\next\dist\next-server\server\next-server.js:124:473)
    at async DevServer.renderToHTML (C:\static\st-client\node_modules\next\dist\server\next-dev-server.js:34:578)

I have installed xmlhttprequest.

Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.