Hi everyone, I've been looking for the past day for solutions to my error in my code with making Discord and Appwrite work on my NextJS project. This project is just a clicker and I'm trying to setup the OAuth so you can't just click without being signed in. I'm not sure why my code doesn't work, but here it is. Also, all of my code provided is from my page.js
and that's the only page I have.
loginWithDiscord Function
const loginWithDiscord = async () => {
try {
await account.createOAuth2Session(
OAuthProvider.Discord,
'http://localhost:3000', // Redirect URL
'http://localhost:3000', // Success URL
['identify', 'email'] // Scopes
);
} catch (error) {
console.error('Error logging in with Discord:', error);
}
};
useEffect for fetching user + clicks
useEffect(() => {
const getUser = async () => {
try {
const user = await account.get();
setUser(user);
fetchClicks();
} catch (error) {
console.error('Error fetching session:', error);
}
};
getUser();
}, []);
Thanks if you can!
Recommended threads
- Is possible to extend timeout function m...
I will have function to backup/aggregate and syncing data. it will take alot of time. anyway to run longer, i expect 1hours
- how ro resend otp?
As the title says, I'm using email otp to authenticate users, I use createSession to send the first otp, but if the user didn't receive the otp how to send it a...
- databases.listDocuments fails when Query...
Hi, databases.listDocuments fails when Query.limit above 1000. Fetch type error: terminated when run inside a function, but seems to work with lower limits, e...