AlexxOriginal post
Web Developer
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
JavaScript
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
JavaScript
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!
Summary
Developers seeking help with setting up OAuth2 for Discord and Appwrite in their NextJS clicker project. They shared code for loginWithDiscord function and useEffect for fetching user and clicks, encountering errors. They are beginners and might be making common mistakes.