return early instead of nesting if/else blocks
This commit is contained in:
1 parent
9fe2de8969
commit
4d12608a22
1 file changed
+7
-6
@@ -151,7 +151,13 @@ class NetworkService {
|
|||||||
|
|
||||||
httpResponse.code = response.status;
|
httpResponse.code = response.status;
|
||||||
|
|
||||||
if (expectedValue) {
|
if (!expectedValue) {
|
||||||
|
// not configure expected value, return
|
||||||
|
httpResponse.status = true;
|
||||||
|
httpResponse.message = this.http.STATUS_CODES[response.status];
|
||||||
|
return httpResponse;
|
||||||
|
}
|
||||||
|
|
||||||
// validate if response data match expected value
|
// validate if response data match expected value
|
||||||
let result = response?.data;
|
let result = response?.data;
|
||||||
|
|
||||||
@@ -195,11 +201,6 @@ class NetworkService {
|
|||||||
httpResponse.status = match;
|
httpResponse.status = match;
|
||||||
httpResponse.message = match ? "Match" : "Not Match";
|
httpResponse.message = match ? "Match" : "Not Match";
|
||||||
return httpResponse;
|
return httpResponse;
|
||||||
}
|
|
||||||
|
|
||||||
httpResponse.status = true;
|
|
||||||
httpResponse.message = this.http.STATUS_CODES[response.status];
|
|
||||||
return httpResponse;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = this.SERVICE_NAME;
|
error.service = this.SERVICE_NAME;
|
||||||
error.method = "requestHttp";
|
error.method = "requestHttp";
|
||||||
|
|||||||
Reference in new issue
Block a user