Skip to content

Commit 3b3de73

Browse files
committed
fix handling of favorite requests in js
1 parent 7593282 commit 3b3de73

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

root/static/js/cpan.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,14 @@ for (const favForm of document.querySelectorAll('form[action="/account/favorite/
228228
favForm.addEventListener('submit', async e => {
229229
e.preventDefault();
230230
const formData = new FormData(favForm);
231-
let response;
232-
try {
233-
response = await fetch(favForm.action, {
234-
method: favForm.method,
235-
headers: {
236-
'Accepts': 'application/json',
237-
},
238-
body: formData,
239-
});
240-
} catch (e) {
231+
const response = await fetch(favForm.action, {
232+
method: favForm.method,
233+
headers: {
234+
'Accept': 'application/json',
235+
},
236+
body: formData,
237+
});
238+
if (!response.ok) {
241239
if (confirm("You have to complete a Captcha in order to ++.")) {
242240
document.location.href = "/account/turing";
243241
}

0 commit comments

Comments
 (0)