getWithoutAuthorization static method
Implementation
static Future<Map<String, dynamic>> getWithoutAuthorization(
String endpoint) async {
Map<String, dynamic> responseMap = {
'status': 0,
'data': null,
'msg': ImosysStrings.somethingWentWrong
};
try {
log("-------$endpoint");
final response = await http
.get(Uri.parse("${ImosysConfig.baseUrl}$endpoint"), headers: {
"Accept": "application/json",
});
log(response.body);
final result = jsonDecode(response.body);
if (result["status"] != null && result["status"] == 1) {
responseMap = {
"status": result["status"] ?? 0,
"data": response.body,
"msg": result["msg"] ?? ImosysStrings.somethingWentWrong
};
} else {
responseMap = {
"status": result["status"] ?? 0,
"data": null,
"msg": result["msg"] ?? ImosysStrings.somethingWentWrong
};
}
return responseMap;
} on SocketException catch (_) {
Map<String, dynamic> responseMap = {
'status': 0,
'data': null,
'msg': ImosysStrings.noInternetConnection
};
return responseMap;
} on TimeoutException catch (_) {
Map<String, dynamic> responseMap = {
'status': 0,
'data': null,
'msg': ImosysStrings.requestTimedOut
};
return responseMap;
} catch (e) {
log(e.toString());
return responseMap;
}
}