kuml2
kuml2

Reputation: 125

How to prevent simultaneous form submissions?

Currently we have an email address submit form that triggers an API call and pass pareters to an API endpoint.

Like this,

<form action="https://www.url.dom/api-endpoint-goes-here" method="post">
  <input type="text" id="name" name="name">
  <input type="email" id="email" name="email">
  <input type="submit" value="Submit">
</form>

Issue: The api endpoint only supports one entry at a time Some rear use-cases where a form is submitted by multiple customers online within 1 to 2 seconds where api endpoint receives entries together, the back-end data causes override issue where only 1 entry receives.

Question: Is there any way to prevent simultaneous multiple submissions at a time that triggers the api endpoint and add some kind of delay process where there is always a delay of a couple of seconds like 1 to 2 sec between each api call?

Upvotes: 0

Views: 87

Answers (1)

Jorge Felico
Jorge Felico

Reputation: 36

The best route for this would be to set up some sort of queuing system where you have a list of submissions and process them one by one on the backend, as opposed to sending the query straight to the final API endpoint.

You can use something like Amazon SQS to push and pull from the queue.

Upvotes: 0

Related Questions