typedef void func(); | |
var jsonResponse; | |
class CallAPI{ | |
static String url = 'https://api.thevirustracker.com/free-api?countryTimeline=US'; | |
static void getData(func f) async{ | |
var response = await http.get(url); | |
if (response.statusCode == 200) { | |
jsonResponse = convert.jsonDecode(response.body); | |
print("API SUCCESS!"); | |
f(); | |
} else { | |
print('Request failed with status: ${response.statusCode}.'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment