DEV Community

Priyansh Agrawal
Priyansh Agrawal

Posted on

HELP!! How to limit multiple API calls after the first call

I have a question: I trigger the POST request upon the button click event. The API creates entries in the database and takes around 1 second on average. My issue is that users can press the button multiple times before the first API request is completed, creating numerous resources. I attempted to implement a pre-check before making any database changes and returning an exception which is then displayed on the UI with an appropriate message. I don't know whether it's the correct way to handle the problem. How can I prevent multiple API calls after the first one?

Top comments (0)