I'm in the midst of a project that involves allowing users to upload multiple files simultaneously. However, sending out numerous requests all at once can overwhelm the server and trigger a 429 (Too Many Requests) error for those requests.
Is there a way to prevent a request from being sent out (without affecting the UI) if there are already a certain number of pending requests?
Below is a simplified code snippet to demonstrate what I am currently implementing:
filesToUpload.forEach(function(file) {
// This function converts the file to base64, prepares the payload,
// makes a POST request, and returns a promise
upload(file, successCallback, errorCallback);
}