Files
Automata/packages/nodes-base/nodes/Mattermost/v1/actions/channel/search/execute.ts
Michael Kret 91d7e16c81 n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
2022-08-17 17:50:24 +02:00

29 lines
854 B
TypeScript

import { IExecuteFunctions } from 'n8n-core';
import { 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);
}