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

fixed the axios dependency issue #90

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions app/api/register/[tournamentId]/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
import { dbConnect } from '../../../../lib/dbConnect';
import Tournament from '../../../../model/Tournament';

export default async function handler(req, res) {
if (req.method !== 'POST') {
return res.status(405).json({ error: 'Method Not Allowed' });
}

export default async function POST(req, res) {

const { tournamentId, teamName, members, inviteCode } = req.body;

if (!tournamentId || !teamName || !members || members.length === 0) {
Expand Down
17 changes: 10 additions & 7 deletions app/tournaments/[id]/register/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
const handleSubmit = async (e) => {
e.preventDefault();
setIsLoading(true);

const formData = {
teamName,
members,
email,
selectedPlatform,
participantType,
};

try {
const response = await axios.post(`/api/register/${tournamentId}`, {
teamName,
members,
email,
selectedPlatform,
participantType
});
const response = await axios.post(`/api/register/${tournamentId}`, formData);
dinxsh marked this conversation as resolved.
Show resolved Hide resolved

if (response.status === 201) {
alert('Registration successful!');
Expand Down
Loading
Loading