mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 22:54:05 -08:00
67983e8f94
* 🐛 Remove useless await for actionNetwork * 🔥 Remove useless await * 🔥 Remove useless await keyword to other generic functions
41 lines
923 B
TypeScript
41 lines
923 B
TypeScript
import { OptionsWithUri } from 'request';
|
|
import {
|
|
IExecuteFunctions,
|
|
IExecuteSingleFunctions,
|
|
IHookFunctions,
|
|
ILoadOptionsFunctions,
|
|
IWebhookFunctions,
|
|
} from 'n8n-core';
|
|
import { IDataObject } from 'n8n-workflow';
|
|
|
|
export async function segmentApiRequest(
|
|
this:
|
|
| IHookFunctions
|
|
| IExecuteFunctions
|
|
| IExecuteSingleFunctions
|
|
| ILoadOptionsFunctions
|
|
| IWebhookFunctions,
|
|
method: string,
|
|
resource: string,
|
|
body: any = {}, // tslint:disable-line:no-any
|
|
qs: IDataObject = {},
|
|
uri?: string,
|
|
_option: IDataObject = {},
|
|
// tslint:disable-next-line:no-any
|
|
): Promise<any> {
|
|
const options: OptionsWithUri = {
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
method,
|
|
qs,
|
|
body,
|
|
uri: uri || `https://api.segment.io/v1${resource}`,
|
|
json: true,
|
|
};
|
|
if (!Object.keys(body).length) {
|
|
delete options.body;
|
|
}
|
|
return this.helpers.requestWithAuthentication.call(this, 'segmentApi', options);
|
|
}
|