Files
Automata/packages/nodes-base/nodes/Mattermost/v1/actions/channel/search/execute.ts
कारतोफ्फेलस्क्रिप्ट™ 7a4e9ef5fa refactor: Remove n8n-core dependency in nodes-base (no-changelog) (#5649)
2023-03-09 18:13:15 +01:00

27 lines
848 B
TypeScript

import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
import { apiRequest } from '../../../transport';
export async function search(
this: IExecuteFunctions,
index: number,
): Promise<INodeExecutionData[]> {
const body = {} as IDataObject;
const qs = {} as IDataObject;
const requestMethod = 'POST';
const teamId = this.getNodeParameter('teamId', index);
const returnAll = this.getNodeParameter('returnAll', 0);
const endpoint = `teams/${teamId}/channels/search`;
body.term = this.getNodeParameter('term', index) as string;
let responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
if (!returnAll) {
const limit = this.getNodeParameter('limit', 0);
responseData = responseData.slice(0, limit);
}
return this.helpers.returnJsonArray(responseData as IDataObject[]);
}