mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-08-25 22:09:40 +00:00
fixes checkEmail error
This commit is contained in:
@ -76,7 +76,9 @@ class UserPermissionApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String?> checkEmail(email) async {
|
|
||||||
|
|
||||||
|
Future<String?> checkEmail(String email) async {
|
||||||
try {
|
try {
|
||||||
final response = await _httpService.post(
|
final response = await _httpService.post(
|
||||||
path: ApiEndpoints.checkEmail,
|
path: ApiEndpoints.checkEmail,
|
||||||
@ -84,16 +86,26 @@ class UserPermissionApi {
|
|||||||
body: {"email": email},
|
body: {"email": email},
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
if (json['statusCode'] != 400) {
|
if (json['statusCode'] != 400) {
|
||||||
return json["message"];
|
var message = json["message"];
|
||||||
|
if (message is String) {
|
||||||
|
return message;
|
||||||
|
} else {
|
||||||
|
return 'Unexpected message format';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return response ?? [];
|
return response ?? 'Unknown error occurred';
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
if (e.response != null) {
|
if (e.response != null) {
|
||||||
|
print(e.response?.data['error']);
|
||||||
final errorMessage = e.response?.data['error'];
|
final errorMessage = e.response?.data['error'];
|
||||||
return errorMessage;
|
return errorMessage is String
|
||||||
|
? errorMessage
|
||||||
|
: 'Error occurred while checking email';
|
||||||
}
|
}
|
||||||
|
return 'Error occurred while checking email';
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return e.toString();
|
return e.toString();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user