Convert result to string

This commit is contained in:
dongfang committed 2025-02-12 02:53:09 +00:00
1 parent 8b49603382
commit b263e2746c
1 file changed
+3 -2
+3 -2
View File
@@ -167,7 +167,7 @@ class NetworkService {
if (contentType && contentType.includes('application/json')) { if (contentType && contentType.includes('application/json')) {
try { try {
result = jmespath.search(result, jsonPath).toString(); result = jmespath.search(result, jsonPath);
} catch (error) { } catch (error) {
httpResponse.status = false; httpResponse.status = false;
httpResponse.message = "JSONPath Search Error"; httpResponse.message = "JSONPath Search Error";
@@ -180,13 +180,14 @@ class NetworkService {
} }
} }
if (!result) { if (result === null || result === undefined) {
httpResponse.status = false; httpResponse.status = false;
httpResponse.message = "Empty Result"; httpResponse.message = "Empty Result";
return httpResponse; return httpResponse;
} }
let match; let match;
result = result.toString();
if (matchMethod === "include") match = result.includes(expectedValue); if (matchMethod === "include") match = result.includes(expectedValue);
else if (matchMethod === "regex") match = new RegExp(expectedValue).test(result); else if (matchMethod === "regex") match = new RegExp(expectedValue).test(result);
else match = result === expectedValue; else match = result === expectedValue;