🥅 Catching an error if Game Pin is invalid in join.svelte
This commit is contained in:
@@ -44,9 +44,21 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let captcha_resp: string;
|
let captcha_resp: string;
|
||||||
const captcha_enabled = (
|
const res = await fetch(`/api/v1/quiz/play/check_captcha/${game_pin}`);
|
||||||
await (await fetch(`/api/v1/quiz/play/check_captcha/${game_pin}`)).json()
|
let captcha_enabled;
|
||||||
).enabled;
|
if (res.status === 200) {
|
||||||
|
captcha_enabled = (await res.json()).enabled;
|
||||||
|
}
|
||||||
|
if (res.status === 404) {
|
||||||
|
alert('Game not found');
|
||||||
|
game_pin = '';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (res.status !== 200) {
|
||||||
|
alert('Unknown error!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (captcha_enabled) {
|
if (captcha_enabled) {
|
||||||
try {
|
try {
|
||||||
const { response } = await hcaptcha.execute(hcaptchaWidgetID, {
|
const { response } = await hcaptcha.execute(hcaptchaWidgetID, {
|
||||||
|
|||||||
Reference in New Issue
Block a user