简体   繁体   中英

How to limit http calls per day in Angular 4 or 5?

I am making an http call on Submit button but I want to limit that calls (say 10 successful calls) per day. Can you Please tell me , how can we implement that in Angular 4/5?

Many Thanks.

Angular are front-end frameworks. You need a back-end application for this implementation.

  • Use Redis or other cache solutions.
  • Use client IP or other as a unique identification key.
  • Check if the key exists, if not, create one.
  • If request succeed, increase the value of the key by INCR command.
  • Check if the value reached 10 of limitation before proceed the request.
  • You can set EXPIRE time to reset a limitation as well.

Redis are not traditional DBs, which means you don't need to waste extra DB queries to do this implementation.

You'll need a backend with a DB counting the number of requests you made that day, and before sending a new request check that DB if the quota hasn't been passed.

saving data across all clients on the front end is not something you can do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM