Handle server rate limit in script.js
In the 'then' function of our AJAX request in script.js, I've added a condition to check for a response status of 429 which indicates too many requests. If this status is encountered, an error message will be shown prompting the user to refresh their CAPTCHA. This is to prevent the user from making excessive attempts unbeknownst to them.
This commit is contained in:
parent
876fcc9e6b
commit
c57a81d76b
@ -152,7 +152,13 @@
|
|||||||
},
|
},
|
||||||
body: JSON.stringify(data)
|
body: JSON.stringify(data)
|
||||||
})
|
})
|
||||||
.then(response => response.json())
|
.then(response => {
|
||||||
|
if (response.status === 429) {
|
||||||
|
setError('Вы превысили количество попыток. Обновите каптчу.', button);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
.then(function (data) {
|
.then(function (data) {
|
||||||
if (typeof data.errors !== 'undefined') {
|
if (typeof data.errors !== 'undefined') {
|
||||||
let errorMessage = '';
|
let errorMessage = '';
|
||||||
|
Loading…
Reference in New Issue
Block a user