Improvements to #1356

This commit is contained in:
ricardo
2021-01-29 00:46:28 -05:00
parent 6ccc104926
commit 73189eda87
2 changed files with 42 additions and 76 deletions

View File

@@ -24,18 +24,20 @@ import {
*
*/
export async function SIGNL4ApiRequest(this: IExecuteFunctions, method: string, contentType: string, body: string, query: IDataObject = {}, teamSecret?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
export async function SIGNL4ApiRequest(this: IExecuteFunctions, method: string, body: string, query: IDataObject = {}, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('signl4Api');
const teamSecret = credentials?.teamSecret as string;
let options: OptionsWithUri = {
headers: {
'Accept': '*/*',
'Content-Type': contentType
},
method,
body,
qs: query,
uri: "https://connect.signl4.com/webhook/" + teamSecret,
json: false,
uri: `https://connect.signl4.com/webhook/${teamSecret}`,
json: true,
};
if (!Object.keys(body).length) {
@@ -46,8 +48,10 @@ export async function SIGNL4ApiRequest(this: IExecuteFunctions, method: string,
}
options = Object.assign({}, options, option);
console.log(options);
try {
return JSON.parse(await this.helpers.request!(options));
return await this.helpers.request!(options);
} catch (error) {
if (error.response && error.response.body && error.response.body.details) {