vendredi 13 mai 2022

How to Dynamically Switch API providers in case one provider is not available

I am working on a project where I want to be able to use any available API. For example, a mobile app needs to display the weather information to a user by obtaining weather data from the backend API and there exist 2 weather APIs(API_1, and API_2) interfaced by my backend. I would like to get the weather information from API_2 in case there is a network error in API_1 and vice versa.

I thought of using if statements but it won't help that much if in the future I decide to add API_n. I appreciate Any guide or link that can help me design a solution for this problem. Thank you

Aucun commentaire:

Enregistrer un commentaire