mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-16 10:45:53 -07:00
Add Log Response Body option
This commit is contained in:
parent
e8d6928078
commit
d69465b229
1 changed files with 15 additions and 0 deletions
|
|
@ -74,6 +74,16 @@ const details = (): IpluginDetails => ({
|
||||||
},
|
},
|
||||||
tooltip: 'Specify request body',
|
tooltip: 'Specify request body',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Log Response Body',
|
||||||
|
name: 'logResponseBody',
|
||||||
|
type: 'boolean',
|
||||||
|
defaultValue: 'false',
|
||||||
|
inputUI: {
|
||||||
|
type: 'switch',
|
||||||
|
},
|
||||||
|
tooltip: 'Specify whether to log response body in the job report',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
outputs: [
|
outputs: [
|
||||||
{
|
{
|
||||||
|
|
@ -93,6 +103,7 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
||||||
const requestUrl = String(args.inputs.requestUrl);
|
const requestUrl = String(args.inputs.requestUrl);
|
||||||
const requestHeaders = JSON.parse(String(args.inputs.requestHeaders));
|
const requestHeaders = JSON.parse(String(args.inputs.requestHeaders));
|
||||||
const requestBody = JSON.parse(String(args.inputs.requestBody));
|
const requestBody = JSON.parse(String(args.inputs.requestBody));
|
||||||
|
const { logResponseBody } = args.inputs;
|
||||||
|
|
||||||
const requestConfig = {
|
const requestConfig = {
|
||||||
method,
|
method,
|
||||||
|
|
@ -104,6 +115,10 @@ const plugin = async (args: IpluginInputArgs): Promise<IpluginOutputArgs> => {
|
||||||
try {
|
try {
|
||||||
const res = await args.deps.axios(requestConfig);
|
const res = await args.deps.axios(requestConfig);
|
||||||
args.jobLog(`Web request succeeded: Status Code: ${res.status}`);
|
args.jobLog(`Web request succeeded: Status Code: ${res.status}`);
|
||||||
|
|
||||||
|
if (logResponseBody) {
|
||||||
|
args.jobLog(`Response Body: ${JSON.stringify(res.data)}`);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
args.jobLog('Web Request Failed');
|
args.jobLog('Web Request Failed');
|
||||||
args.jobLog(JSON.stringify(err));
|
args.jobLog(JSON.stringify(err));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue