Browse Source

fix: error when reference array column in webhook

Ahmad Kholid 3 years ago
parent
commit
b43fe6eb10
2 changed files with 4 additions and 2 deletions
  1. 3 1
      src/utils/reference-data/mustache-replacer.js
  2. 1 1
      src/utils/webhookUtil.js

+ 3 - 1
src/utils/reference-data/mustache-replacer.js

@@ -28,7 +28,9 @@ export default function (str, data) {
     const { dataKey, path } = keyParser(key);
     const { dataKey, path } = keyParser(key);
     const result = getObjectPath(data[dataKey], path) ?? match;
     const result = getObjectPath(data[dataKey], path) ?? match;
 
 
-    return isObject(result) ? JSON.stringify(result) : result;
+    return isObject(result) || Array.isArray(result)
+      ? JSON.stringify(result)
+      : result;
   });
   });
 
 
   return replacedStr;
   return replacedStr;

+ 1 - 1
src/utils/webhookUtil.js

@@ -50,7 +50,7 @@ export async function executeWebhook({
   const id = setTimeout(() => {
   const id = setTimeout(() => {
     controller.abort();
     controller.abort();
   }, timeout);
   }, timeout);
-
+  console.log(body);
   try {
   try {
     const finalHeaders = filterHeaders(headers);
     const finalHeaders = filterHeaders(headers);
     const finalContent = renderContent(body, contentType);
     const finalContent = renderContent(body, contentType);