Created
September 30, 2020 03:14
-
-
Save datasciencemonkey/f61914ce2731549388bd7c96d03acbe7 to your computer and use it in GitHub Desktop.
networkHelper to fire requests off to ESP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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