I have a python program that gets data from an API. This data changes every few minutes. The program currently runs without any issue other than my refresh function that is called in multiple places.
Sample code:
import requests
import json
import time
url = 'https://api.url.com/...'
resp = requests.get(url)
data = resp.json()
def refresh_data():
resp = requests.get(url)
data = resp.json()
while True:
print(data)
#This will not refresh the response
refresh_data()
#This will refresh (But I need it in function)
#resp = requests.get(url)
#data = resp.json()
sleep(60)
I would like any suggestions on how to make my refresh function work. I will be calling it from other functions as well as other python files.