22 lines
692 B
TypeScript
22 lines
692 B
TypeScript
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
|
|
|
import { apiRequest } from '../../../transport';
|
|
|
|
export async function addUser(
|
|
this: IExecuteFunctions,
|
|
index: number,
|
|
): Promise<INodeExecutionData[]> {
|
|
const channelId = this.getNodeParameter('channelId', index) as string;
|
|
|
|
const body = {} as IDataObject;
|
|
const qs = {} as IDataObject;
|
|
const requestMethod = 'POST';
|
|
const endpoint = `channels/${channelId}/members`;
|
|
|
|
body.user_id = this.getNodeParameter('userId', index) as string;
|
|
|
|
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
|
|
|
return this.helpers.returnJsonArray(responseData as IDataObject[]);
|
|
}
|