Fixed possible undefined error

This commit is contained in:
Ashten 2025-01-18 23:06:39 -08:00
parent 7ed25ef7f5
commit bf1dac8e8b

View file

@ -98,12 +98,11 @@ export class CaptchaService {
const resp = await result.json() as CaptchaResponse; const resp = await result.json() as CaptchaResponse;
if (resp.success !== true) { if (resp.success !== true) {
const errorCodes = resp['error-codes'] ? resp['errors'].join(', ') : ''; const errorCodes = resp['error-codes'] ? resp['errors']?.join(', ') : '';
throw new Error(`frc-failed: ${errorCodes}`); throw new Error(`frc-failed: ${errorCodes}`);
} }
} }
// https://codeberg.org/Gusted/mCaptcha/src/branch/main/mcaptcha.go // https://codeberg.org/Gusted/mCaptcha/src/branch/main/mcaptcha.go
@bindThis @bindThis
public async verifyMcaptcha(secret: string, siteKey: string, instanceHost: string, response: string | null | undefined): Promise<void> { public async verifyMcaptcha(secret: string, siteKey: string, instanceHost: string, response: string | null | undefined): Promise<void> {