In the event that my primary API is unresponsive, I want my front-end application to automatically switch to a secondary API.
For instance, when calling results in a net::ERR_CONNECTION_TIMED_OUT
error (as seen in Chrome XHR response), signifying that the primary API is down, I would like the front-end to then call .
I have reviewed the documentation for AngularJS 1.5.7 $resource, which mentions an action parameter timeout
of type {number}
. However, even setting it to 500 still triggers the net::ERR_CONNECTION_TIMED_OUT
after around 2 minutes!
Desired workflow:
- Make request to
- If no response within 10 seconds:
- Switch to
- Continue switching between APIs as long as backends are available
Pseudocode:
angular.forEach(fallback_urls, function(url) {
$resource(url + '/users?name=bob', {}, {timeout: 10}).get()
});