mirror of
https://github.com/n8n-io/n8n-nodes-starter.git
synced 2025-10-28 22:12:26 -05:00
Refactoring
This commit is contained in:
parent
5e04f87fea
commit
6c337cfb6e
2 changed files with 12 additions and 18 deletions
|
|
@ -1,11 +1,8 @@
|
|||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
ICredentialsDecrypted,
|
||||
ICredentialTestFunctions,
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
INodeCredentialTestResult,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
|
|
@ -93,7 +90,8 @@ export class FriendGrid implements INodeType {
|
|||
message: `${response.error}`,
|
||||
};
|
||||
}
|
||||
} catch (err) {
|
||||
// tslint:disable-next-line:no-any
|
||||
} catch (err: any) {
|
||||
return {
|
||||
status: 'Error',
|
||||
message: `${err.message}`,
|
||||
|
|
@ -115,7 +113,7 @@ export class FriendGrid implements INodeType {
|
|||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
let body: IDataObject = {};
|
||||
const qs: IDataObject = {};
|
||||
const qs: IDataObject = {}; // query string
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
try {
|
||||
|
|
@ -124,12 +122,9 @@ export class FriendGrid implements INodeType {
|
|||
// https://docs.sendgrid.com/api-reference/contacts/add-or-update-a-contact
|
||||
|
||||
const email = this.getNodeParameter('email', i) as string;
|
||||
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const data: IDataObject = {
|
||||
email,
|
||||
};
|
||||
|
||||
const data: IDataObject = { email };
|
||||
Object.assign(data, additionalFields);
|
||||
|
||||
body = {
|
||||
|
|
@ -147,7 +142,8 @@ export class FriendGrid implements INodeType {
|
|||
} else if (responseData !== undefined) {
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
} catch (error) {
|
||||
// tslint:disable-next-line:no-any
|
||||
} catch (error: any) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ error: error.message });
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -3,14 +3,11 @@ import {
|
|||
} from 'request';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
IExecuteSingleFunctions,
|
||||
IHookFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
|
@ -29,7 +26,7 @@ export async function friendGridApiRequest(this: IHookFunctions | IExecuteFuncti
|
|||
const options: OptionsWithUri = {
|
||||
method,
|
||||
headers: {
|
||||
'Accept': ' application/json',
|
||||
'Accept': 'application/json',
|
||||
'Authorization': `Bearer ${credentials.apiKey}`,
|
||||
},
|
||||
qs,
|
||||
|
|
@ -47,7 +44,8 @@ export async function friendGridApiRequest(this: IHookFunctions | IExecuteFuncti
|
|||
|
||||
try {
|
||||
return this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
// tslint:disable-next-line:no-any
|
||||
} catch (error: any) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue