getHomeData method
Implementation
Future getHomeData() async {
var checkStatusCode;
try {
var decodedResponse;
final response = await http.get(
Uri.parse('${choice_Base_Url}choice/homepage'),
headers: {"Authorization": choiceToken});
TokenRefresh(refreshtoken: response.headers['authorization'].toString());
checkStatusCode = response.statusCode;
decodedResponse = json.decode(response.body);
if (response.statusCode == 200) {
homeDetails = decodedResponse['data'];
} else {
getErrorMessage(decodedResponse['message']);
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.clear();
Navigator.popAndPushNamed(commonContext, '/wellnesspage');
}
} catch (err) {
AutoLogoutThreeTry();
if (checkStatusCode == 401) {
await getHomeData();
(commonContext as Element).reassemble();
} else {}
}
}