|
|
@ -116,20 +116,33 @@ export async function handleHttpWebHook(apiMeta, user, data) { |
|
|
|
|
|
|
|
|
|
|
|
export function axiosRequestMake(_apiMeta, _user, data) { |
|
|
|
export function axiosRequestMake(_apiMeta, _user, data) { |
|
|
|
const apiMeta = { ..._apiMeta }; |
|
|
|
const apiMeta = { ..._apiMeta }; |
|
|
|
|
|
|
|
// if it's a string try to parse and apply handlebar
|
|
|
|
|
|
|
|
// or if object then convert into JSON string and parse it
|
|
|
|
if (apiMeta.body) { |
|
|
|
if (apiMeta.body) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
apiMeta.body = JSON.parse(apiMeta.body, (_key, value) => { |
|
|
|
apiMeta.body = JSON.parse( |
|
|
|
return typeof value === 'string' ? parseBody(value, data) : value; |
|
|
|
typeof apiMeta.body === 'string' |
|
|
|
}); |
|
|
|
? apiMeta.body |
|
|
|
|
|
|
|
: JSON.stringify(apiMeta.body), |
|
|
|
|
|
|
|
(_key, value) => { |
|
|
|
|
|
|
|
return typeof value === 'string' ? parseBody(value, data) : value; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
// if string parsing failed then directly apply the handlebar
|
|
|
|
apiMeta.body = parseBody(apiMeta.body, data); |
|
|
|
apiMeta.body = parseBody(apiMeta.body, data); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (apiMeta.auth) { |
|
|
|
if (apiMeta.auth) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
apiMeta.auth = JSON.parse(apiMeta.auth, (_key, value) => { |
|
|
|
apiMeta.auth = JSON.parse( |
|
|
|
return typeof value === 'string' ? parseBody(value, data) : value; |
|
|
|
typeof apiMeta.auth === 'string' |
|
|
|
}); |
|
|
|
? apiMeta.auth |
|
|
|
|
|
|
|
: JSON.stringify(apiMeta.auth), |
|
|
|
|
|
|
|
(_key, value) => { |
|
|
|
|
|
|
|
return typeof value === 'string' ? parseBody(value, data) : value; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
apiMeta.auth = parseBody(apiMeta.auth, data); |
|
|
|
apiMeta.auth = parseBody(apiMeta.auth, data); |
|
|
|
} |
|
|
|
} |
|
|
|