Problem
The /create_invite_link API assumes that the inviter always exists and has an invites array.
If checkInviteLink() returns an empty result, the code tries to access:
which causes:
TypeError: Cannot read properties of undefined (reading 'invites')
Invalid inviter_id or server_id values can also cause MongoDB errors.
Expected Behavior
- Invalid IDs should return a proper error.
- Missing inviter data should be handled safely.
- The API should not crash when no invite data exists.
Suggested Fix
- Validate
inviter_id and server_id.
- Check if
response is empty before accessing response[0].invites.
- Wrap database operations in
try/catch to handle errors gracefully.
Problem
The
/create_invite_linkAPI assumes that the inviter always exists and has aninvitesarray.If
checkInviteLink()returns an empty result, the code tries to access:which causes:
Invalid
inviter_idorserver_idvalues can also cause MongoDB errors.Expected Behavior
Suggested Fix
inviter_idandserver_id.responseis empty before accessingresponse[0].invites.try/catchto handle errors gracefully.