fetch method
Fetchs data from the JSON API and returns a decoded JSON.
Implementation
Future<http.Response> fetch(String type, {Map<String, String> query}) async {
var client = http.Client();
http.Response response;
try {
response = await client.get(
'https://us-central1-smartrider-4e9e8.cloudfunctions.net/$type',
headers: query);
//await createJSONFile('$type', response);
if (response.statusCode == 200) {
isConnected = true;
}
} catch (error) {
isConnected = false;
}
//print("App has polled $type API: $isConnected");
return response;
}