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

fetch is not defined #11

Closed
JcynR opened this issue Feb 28, 2023 · 7 comments
Closed

fetch is not defined #11

JcynR opened this issue Feb 28, 2023 · 7 comments

Comments

@JcynR
Copy link

JcynR commented Feb 28, 2023

I tried installing node-fetch manually but it didn't fix it.

client.js:193
const request = await fetch('https://beta.character.ai/chat/auth/lazy/', {
                ^
ReferenceError: fetch is not defined
@realcoloride
Copy link
Owner

Hello
do npm install node-fetch

@JcynR
Copy link
Author

JcynR commented Feb 28, 2023

I did that already.

@JcynR
Copy link
Author

JcynR commented Feb 28, 2023

Looks like you didn't import the package in client.js

@realcoloride
Copy link
Owner

I don't have to, it works without having to require anything

Though you might wanna install cross fetch, in what environment and node version do you run?

@JcynR
Copy link
Author

JcynR commented Feb 28, 2023

Okay, I see what's happening,I'm running v16.6.2 but in version 18.0.0 they apparently added fetch to the global scope

Check it:
https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V18.md#fetch-experimental

I may have to upgrade then... but I can't at this time. Maybe you should make that clear or make it compatible with older versions.

@realcoloride
Copy link
Owner

realcoloride commented Mar 1, 2023 via email

@JcynR
Copy link
Author

JcynR commented Mar 2, 2023

I upgraded to v18 so for me it's not a problem anymore. But if you want to make it compatible with older versions, you could just use the node-fetch library instead. All you have to do is import it.

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

No branches or pull requests

2 participants