Skip to content

Commit

Permalink
fix loading error discord
Browse files Browse the repository at this point in the history
  • Loading branch information
manishpali17 committed May 22, 2024
1 parent 7368c83 commit 7c4a2cc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/app/discord/redirect/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import { useEffect, useState } from 'react';

export default function DiscordOauthRedirect() {
const [loading, setLoading] = useState(true);
const [error, setError] = useState(false);
const [error, setError] = useState('');
const searchParams = useSearchParams();
const code = searchParams.get('code');
const discordError = searchParams.get('error');

const updateDiscordUser = async (code: string) => {
try {
Expand Down Expand Up @@ -39,7 +40,11 @@ export default function DiscordOauthRedirect() {
if (code) {
updateDiscordUser(code);
}
}, [code]);
if (discordError) {
setLoading(false);
setError(discordError);
}
}, [code, discordError]);

if (loading) {
return <div>Loading...</div>;
Expand Down

0 comments on commit 7c4a2cc

Please sign in to comment.