Skip to content

Instantly share code, notes, and snippets.

@datasciencemonkey
Created September 30, 2020 03:14
Show Gist options
  • Save datasciencemonkey/f61914ce2731549388bd7c96d03acbe7 to your computer and use it in GitHub Desktop.
Save datasciencemonkey/f61914ce2731549388bd7c96d03acbe7 to your computer and use it in GitHub Desktop.
networkHelper to fire requests off to ESP
class NetworkHelper {
NetworkHelper(this.url);
final String url;
final Xml2Json xml2json = new Xml2Json();
Future getData() async {
print(url);
http.Response response =
await http.get(url, headers: {'Accept': 'application/json'});
if (response.statusCode == 200) {
print(response.body);
var data = response.body;
return jsonDecode(data);
} else {
print(response.statusCode);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment