Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement angular.js retry with exponential back-off?

Tags:

angularjs

How would I implement retry logic in angular.js with exponential back-off?

  1. Would the right place for the logic be in $httpProvider.requestInterceptors?
  2. Can I selectively pick to use it with some $http services and not others?
like image 935
Pavel Hlobil Avatar asked Apr 10 '26 11:04

Pavel Hlobil


1 Answers

This is an old post, but here's my thoughts. I'd use a responseInterceptor. Since you can just return another promise, you can decide how to retry. You have access the the $http config in the interceptor, so you can add special configuration to determine what the back-off should be (or whether to apply the retry logic at all).

like image 114
Kevin Stone Avatar answered Apr 12 '26 02:04

Kevin Stone



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!