n8n/packages/nodes-base/nodes/Dropcontact/GenericFunction.ts
agobrech 67983e8f94
fix: Remove redundant await in node's api request functions without try/catch (#4639)
* 🐛 Remove useless await for actionNetwork

* 🔥 Remove useless await

* 🔥 Remove useless await keyword to other generic functions
2022-11-22 17:57:17 +01:00

35 lines
752 B
TypeScript

import { IExecuteFunctions, IHookFunctions } from 'n8n-core';
import { IDataObject, ILoadOptionsFunctions } from 'n8n-workflow';
import { OptionsWithUri } from 'request';
/**
* Make an authenticated API request to Bubble.
*/
export async function dropcontactApiRequest(
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
method: string,
endpoint: string,
body: IDataObject,
qs: IDataObject,
) {
const options: OptionsWithUri = {
method,
uri: `https://api.dropcontact.io${endpoint}`,
qs,
body,
json: true,
};
if (!Object.keys(body).length) {
delete options.body;
}
if (!Object.keys(qs).length) {
delete options.qs;
}
return this.helpers.requestWithAuthentication.call(this, 'dropcontactApi', options);
}