Open Gauravtb2253 opened 6 days ago
Hello I would like to work on displaying the club with their members. Pls assign me
But first we have to create a the add club memebers functionality. refer the prisma schema,i have made tables in db.
Actually I am getting some error while adding new club member can you pls guide for this
I have compiled the ts code and also included proper routes and functions in the backend
It would be nice if you tell something like what can I do or if you have faced similar kind of error before
Thank you
Actually I am getting some error while adding new club member can you pls guide for this
I have compiled the ts code and also included proper routes and functions in the backend
It would be nice if you tell something like what can I do or if you have faced similar kind of error before
Thank you
Could you try logging the whole error message so that we can find the solution?
I think this could be some problems:
export const addClubMember = async (req: Request, res: Response) => {
try {
const { ClubID } = req.body;
if (!ClubID) {
logger.warn("Attempted to add club member with missing required fields.");
return res
.status(400)
.json({ error: "ClubID is required." });
}
const newMember = await prisma.clubMember.create({
data: {
ClubID,
FirstName: req.body.FirstName,
LastName: req.body.LastName,
Email: req.body.Email,
Role: req.body.Role,
JoinDate: req.body.JoinDate,
ProfileImageURL: req.body.ProfileImageURL,
},
});
logger.info(`New member added to ClubID: ${ClubID}`);
res.status(201).json(newMember);
} catch (error) {
logger.error(`Error adding club member: ${error}`);
res
.status(500)
.json({ error: "An error occurred while adding club member."+error });
}
};
you can verify this by sending request through: http://localhost:4000/api/clubs/addMember
demo data:
{
"ClubID":10,
"FirstName":"Sami",
"LastName":"Bhangaonkar",
"Email":"sami@gmail.com",
"Role":"developer",
"JoinDate":"10/10/2024",
"ProfileImageURL":"https://demo.png"
}
@Gauravtb2253 , try these solutions or you can tell me to do the backend stuff for you
export const addClubMember = async (req: Request, res: Response) => {
try {
const {
ClubID,
FirstName,
LastName,
Email,
Role,
JoinDate,
ProfileImageURL
} = req.body;
console.log(req.body)
if (!ClubID || !FirstName || !LastName) {
logger.warn(
"Attempted to add a club member with missing required fields."
);
return res
.status(400)
.json({ error: "ClubID, FirstName, and LastName are required." });
}
const newMember = await prisma.clubMember.create({
data: {
FirstName,
LastName,
Email,
Role,
JoinDate,
ProfileImageURL,
Club: {
connect: { ClubID }
}
},
});
logger.info(
New member added to ClubID ${ClubID}: ${FirstName} ${LastName}
);
res.status(201).json(newMember);
} catch (error) {
logger.error(Error adding club member: ${error}
);
res.status(500).json({ error: "Error adding club member" });
}
};
this is my code for adding member
{ "ClubID": 1, "FirstName": "abc", "LastName": "def", "Email": "abc@gmail.com", "Role": "Member", "JoinDate": "2024-10-17", "ProfileImageURL": "url" }
this is demo data
I am getting internal server error
{ "ClubID": 1, "FirstName": "abc", "LastName": "def", "Email": "abc@gmail.com", "Role": "Member", "JoinDate": "2024-10-17", "ProfileImageURL": "url" }
this is demo data
Sorry but the club for club id 1 there is no club present, that's why the error was coming i think.
refer the below image for adding member to specific club with there id mentioned. when we login we get the club id in response for that logged club.use that to add the club member when adding thourgh the webaite.
Can you give me email and password for any one club pls for login purpose
Can you give me email and password for any one club pls for login purpose
demo@gmail.com pass: 123456
Bro when I am using localhost for adding a new club then I am unables to do it But when I do with the render url it works
Same with the case of login
So is there any setting that you need to do in your render backend server to add my route of adding club member
On backend file axiosInstance.tsx change the url from onrender backend url to http://localhost:4000 See, on render there isn't a route to add member ,its at your local,when we push these changes the onrender will work to addmember. just remember to change it back to onrender url when pushing.
the error is solved I will try to do the work till tonight
the error is solved I will try to do the work till tonight
ok,great
Just pull the latest changes or it could create conflicts further
Hello I would like to work on displaying the club with their members. Pls assign me