froth-webdriverio-framework 3.0.129 → 3.0.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/froth_common_actions/apicall.js +20 -20
- package/package.json +1 -1
|
@@ -17,8 +17,8 @@ async function callapi(methodtype, api_url, queryParams, payloaddetails, body_ty
|
|
|
17
17
|
let headers = await formheaders(authentication, headersdetails, body_type);
|
|
18
18
|
let body = null;
|
|
19
19
|
console.log("Body Type:", body_type);
|
|
20
|
-
console.log("method:",method);
|
|
21
|
-
console.log("headers:",headers);
|
|
20
|
+
console.log("method:", method);
|
|
21
|
+
console.log("headers:", headers);
|
|
22
22
|
if (body_type === "raw" && payloaddetails && Object.keys(payloaddetails).length > 0) {
|
|
23
23
|
console.log("Payload (JSON):", JSON.stringify(payloaddetails));
|
|
24
24
|
body = JSON.stringify(payloaddetails);
|
|
@@ -35,23 +35,23 @@ async function callapi(methodtype, api_url, queryParams, payloaddetails, body_ty
|
|
|
35
35
|
|
|
36
36
|
// console.log("options:", JSON.stringify(options, null, 2));
|
|
37
37
|
// Send the request
|
|
38
|
-
if (method === 'GET' && body) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
} else {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
38
|
+
// if (method === 'GET' && body) {
|
|
39
|
+
console.warn("Warning: GET request with a body is non-standard and may not work with all APIs.");
|
|
40
|
+
response = await axios({
|
|
41
|
+
method: method,
|
|
42
|
+
url: api_url,
|
|
43
|
+
headers: headers,
|
|
44
|
+
data: body === null ? undefined : body // Axios allows body with GET in some cases
|
|
45
|
+
});
|
|
46
|
+
// } else {
|
|
47
|
+
// // ✅ Use Fetch for other request types
|
|
48
|
+
// response = await fetch(api_url, {
|
|
49
|
+
// method,
|
|
50
|
+
// headers,
|
|
51
|
+
// body: method !== 'GET' ? body : null, // Fetch does NOT allow body in GET
|
|
52
|
+
// });
|
|
53
|
+
// }
|
|
54
|
+
|
|
55
55
|
console.log("Response Data:", response);
|
|
56
56
|
|
|
57
57
|
} catch (error) {
|
|
@@ -88,7 +88,7 @@ async function formheaders(authentication, headers, body_type) {
|
|
|
88
88
|
if (!headers || typeof headers !== "object") {
|
|
89
89
|
headers = {};
|
|
90
90
|
}
|
|
91
|
-
if(body_type === "raw"){
|
|
91
|
+
if (body_type === "raw") {
|
|
92
92
|
headers['Content-Type'] = 'application/json';
|
|
93
93
|
}
|
|
94
94
|
// Add authentication headers based on the type
|