I'm requesting API data through axios using RapidAPI's Apis.
I followed all the documentations provided in RapidAPI with a relatively simple code. However, when I log the values, it keeps repeatedly requesting data over and over and this in turn hikes up my requests from RapidAPI and uses a lot of resources and money. I can't figure out how to only retrieve the values ONCE. Here are my codes.
My React .tsx file
const [sportsData, setSportsData] = useState() 
const fetchSportsData = () => {
axios
  .request(testApi)
  .then((response) => {
    setSportsData(response.data)
  })
  .catch((error) => {
    console.log(error)
  })
} 
fetchSportsData()
console.log(sportsData)
My Api File
export const testApi = {
method: 'GET',
url: 'https://api-football-v1.p.rapidapi.com/v3/timezone',
 headers: {
 'X-RapidAPI-Key': '-------removed on purpose ---------',
 'X-RapidAPI-Host': 'api-football-v1.p.rapidapi.com'
 }
}
I am just setting the data using useState but it seems to repeatedly rerender whenever a value is stored. I've tried many roundabout ways but it seems to repeatedly request over and over again. Has anyone used API's from RapidAPI before?
