Browse Source

fix: pass payload in test webhook

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/1917/head
Pranav C 3 years ago
parent
commit
985416e8c4
  1. 13
      packages/nc-gui/components/project/tableTabs/webhook/webhookEditor.vue
  2. 25
      packages/nocodb/src/lib/noco/meta/helpers/webhookHelpers.ts

13
packages/nc-gui/components/project/tableTabs/webhook/webhookEditor.vue

@ -229,12 +229,12 @@
:model-id="meta.id" :model-id="meta.id"
hide-test-btn hide-test-btn
:hook="{ :hook="{
...hook, ...hook,
filters, filters,
notification: { notification: {
...hook.notification, ...hook.notification,
payload: notification, payload: notification,
}, },
}" }"
/> />
</v-card-text> </v-card-text>
@ -254,6 +254,7 @@ export default {
meta: Object meta: Object
}, },
data: () => ({ data: () => ({
notification: {},
hook: { hook: {
notification: { notification: {
type: 'URL' type: 'URL'

25
packages/nocodb/src/lib/noco/meta/helpers/webhookHelpers.ts

@ -112,26 +112,26 @@ export async function validateCondition(filters: Filter[], data: any) {
return isValid; return isValid;
} }
export async function handleHttpWebHook(apiMeta, apiReq, data) { export async function handleHttpWebHook(apiMeta, user, data) {
// try { // try {
const req = axiosRequestMake(apiMeta, apiReq, data); const req = axiosRequestMake(apiMeta, user, data);
await require('axios')(req); await require('axios')(req);
// } catch (e) { // } catch (e) {
// console.log(e); // console.log(e);
// } // }
} }
export function axiosRequestMake(_apiMeta, apiReq, data) { export function axiosRequestMake(_apiMeta, user, data) {
const apiMeta = { ..._apiMeta }; const apiMeta = { ..._apiMeta };
if (apiMeta.body) { if (apiMeta.body) {
try { try {
apiMeta.body = JSON.parse(apiMeta.body, (_key, value) => { apiMeta.body = JSON.parse(apiMeta.body, (_key, value) => {
return typeof value === 'string' return typeof value === 'string'
? parseBody(value, apiReq, data, apiMeta) ? parseBody(value, user, data, apiMeta)
: value; : value;
}); });
} catch (e) { } catch (e) {
apiMeta.body = parseBody(apiMeta.body, apiReq, data, apiMeta); apiMeta.body = parseBody(apiMeta.body, user, data, apiMeta);
console.log(e); console.log(e);
} }
} }
@ -139,11 +139,11 @@ export function axiosRequestMake(_apiMeta, apiReq, data) {
try { try {
apiMeta.auth = JSON.parse(apiMeta.auth, (_key, value) => { apiMeta.auth = JSON.parse(apiMeta.auth, (_key, value) => {
return typeof value === 'string' return typeof value === 'string'
? parseBody(value, apiReq, data, apiMeta) ? parseBody(value, user, data, apiMeta)
: value; : value;
}); });
} catch (e) { } catch (e) {
apiMeta.auth = parseBody(apiMeta.auth, apiReq, data, apiMeta); apiMeta.auth = parseBody(apiMeta.auth, user, data, apiMeta);
console.log(e); console.log(e);
} }
} }
@ -152,17 +152,12 @@ export function axiosRequestMake(_apiMeta, apiReq, data) {
params: apiMeta.parameters params: apiMeta.parameters
? apiMeta.parameters.reduce((paramsObj, param) => { ? apiMeta.parameters.reduce((paramsObj, param) => {
if (param.name && param.enabled) { if (param.name && param.enabled) {
paramsObj[param.name] = parseBody( paramsObj[param.name] = parseBody(param.value, user, data, apiMeta);
param.value,
apiReq,
data,
apiMeta
);
} }
return paramsObj; return paramsObj;
}, {}) }, {})
: {}, : {},
url: parseBody(apiMeta.path, apiReq, data, apiMeta), url: parseBody(apiMeta.path, user, data, apiMeta),
method: apiMeta.method, method: apiMeta.method,
data: apiMeta.body, data: apiMeta.body,
headers: apiMeta.headers headers: apiMeta.headers
@ -170,7 +165,7 @@ export function axiosRequestMake(_apiMeta, apiReq, data) {
if (header.name && header.enabled) { if (header.name && header.enabled) {
headersObj[header.name] = parseBody( headersObj[header.name] = parseBody(
header.value, header.value,
apiReq, user,
data, data,
apiMeta apiMeta
); );

Loading…
Cancel
Save