Files
Automata/packages/nodes-base/nodes/Mattermost/v1/actions/reaction/getAll/execute.ts
Iván Ovejero 0565194473 refactor(core): Introduce overload for number-type node parameter (no-changelog) (#4644)
* 📘 Set up overloads

* 📘 Add temporary assertion

* 🔥 Remove inferrable number assertions

* ✏️ Add ticket ref
2022-11-18 15:26:22 +01:00

25 lines
737 B
TypeScript

import { IExecuteFunctions } from 'n8n-core';
import { IDataObject, INodeExecutionData } from 'n8n-workflow';
import { apiRequest } from '../../../transport';
export async function getAll(
this: IExecuteFunctions,
index: number,
): Promise<INodeExecutionData[]> {
const postId = this.getNodeParameter('postId', index) as string;
const limit = this.getNodeParameter('limit', 0, 0);
const qs = {} as IDataObject;
const requestMethod = 'GET';
const endpoint = `posts/${postId}/reactions`;
const body = {} as IDataObject;
let responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
if (limit > 0) {
responseData = responseData.slice(0, limit);
}
return this.helpers.returnJsonArray(responseData);
}