edit http status to catch and print any error belongs to the statusCode (#84)

This commit is contained in:
ibraheem alsamaraie
2021-07-25 21:42:18 +03:00
committed by GitHub
parent d409e4a19c
commit 510d27d1e7

View File

@ -35,8 +35,15 @@ class MyGetHttpDataState extends State<MyGetHttpData> {
setState(() {
// Get the JSON data
var dataConvertedToJSON = json.decode(response.body);
try{
if(dataConvertedToJSON.statusCode == 200){
data = dataConvertedToJSON['results'];
}
}
catch(e){
print(dataConvertedToJSON.statusCode);
}
// Extract the required part and assign it to the global variable named data
data = dataConvertedToJSON['results'];
});
return "Successfull";