getUserProfile method
To get user profile data in whitelabel app user needs to use below API
Implementation
Future<http.Response> getUserProfile() async {
Uri url = Uri.parse("$_baseUrl/user/profile");
http.Response response = await http.Client().get(
url,
headers: kAuthenticatedGetRequestHeader,
);
if (response.statusCode == 200) {
printMessage("GET USER PROFILE RESPONSE = ${response.body}");
UserModel userModel = UserModel.fromJson(jsonDecode(response.body));
SharedPreference.setUser(userModel: userModel);
kAuthenticatedPostRequestHeader = {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Token ${SharedPreference.getUser()!.token}"
};
kAuthenticatedGetRequestHeader = {
"Accept": "application/json",
"Authorization": "Token ${SharedPreference.getUser()!.token}"
};
return response;
} else {
printMessage("GET USER PROFILE RESPONSE = ${response.statusCode}");
printMessage("GET USER PROFILE RESPONSE = ${response.body}");
return response;
}
}