Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3645

How can I make Axios try with multiple urls and if one of them working then return data

$
0
0

Like the title, I'm working on an app that calls the YouTube APIs but sometimes my app makes too many requests that trigger the API quotas limit and thus making the app stop working due to error on the API server. The solution for this which I found on the Internet is to create multiple API keys and looping through them. But I'm having a headache figuring out how to make my Axios trying multiple API URLs before returning the data. Any tips or tricks on this?

Here is the sample code I tried:

async function getYoutubeVideoSnippet(id) {  const response = await axios.all([    axios.get("https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics&id=" +        id +"&key=API_KEY"    ),    axios.get("https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics&id=" +        id +"&key=API_KEY"    ),  ]);  return response.data;}

Viewing all articles
Browse latest Browse all 3645

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>