use stringService in requestHttp

This commit is contained in:
dongfang committed 2025-02-12 03:16:07 +00:00
1 parent 6837adb5aa
commit 1f0876dd71
1 file changed
+5 -5
+5 -5
View File
@@ -144,7 +144,7 @@ class NetworkService {
const code = error.response?.status || this.NETWORK_ERROR; const code = error.response?.status || this.NETWORK_ERROR;
httpResponse.code = code; httpResponse.code = code;
httpResponse.status = false; httpResponse.status = false;
httpResponse.message = this.http.STATUS_CODES[code] || "Network Error"; httpResponse.message = this.http.STATUS_CODES[code] || this.stringService.httpNetworkError;
return httpResponse; return httpResponse;
} }
@@ -173,7 +173,7 @@ class NetworkService {
const isJson = contentType?.includes('application/json'); const isJson = contentType?.includes('application/json');
if (!isJson) { if (!isJson) {
httpResponse.status = false; httpResponse.status = false;
httpResponse.message = "Response Not JSON"; httpResponse.message = this.stringService.httpNotJson;
return httpResponse; return httpResponse;
} }
@@ -181,14 +181,14 @@ class NetworkService {
result = jmespath.search(result, jsonPath); result = jmespath.search(result, jsonPath);
} catch (error) { } catch (error) {
httpResponse.status = false; httpResponse.status = false;
httpResponse.message = "JSONPath Search Error"; httpResponse.message = this.stringService.httpJsonPathError;
return httpResponse; return httpResponse;
} }
} }
if (result === null || result === undefined) { if (result === null || result === undefined) {
httpResponse.status = false; httpResponse.status = false;
httpResponse.message = "Empty Result"; httpResponse.message = this.stringService.httpEmptyResult;
return httpResponse; return httpResponse;
} }
@@ -199,7 +199,7 @@ class NetworkService {
else match = result === expectedValue; else match = result === expectedValue;
httpResponse.status = match; httpResponse.status = match;
httpResponse.message = match ? "Match" : "Not Match"; httpResponse.message = match ? this.stringService.httpMatchSuccess : this.stringService.httpMatchFail;
return httpResponse; return httpResponse;
} catch (error) { } catch (error) {
error.service = this.SERVICE_NAME; error.service = this.SERVICE_NAME;