mirror of
https://github.com/n8n-io/n8n-nodes-starter.git
synced 2025-10-29 06:22:24 -05:00
Merge 14bf7f8604 into 67ee5b8e80
This commit is contained in:
commit
055d11f5b4
1 changed files with 3 additions and 2 deletions
|
|
@ -39,6 +39,7 @@ export class ExampleNode implements INodeType {
|
||||||
// You can make async calls and use `await`.
|
// You can make async calls and use `await`.
|
||||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
const items = this.getInputData();
|
const items = this.getInputData();
|
||||||
|
const itemCount = items.length;
|
||||||
|
|
||||||
let item: INodeExecutionData;
|
let item: INodeExecutionData;
|
||||||
let myString: string;
|
let myString: string;
|
||||||
|
|
@ -46,7 +47,7 @@ export class ExampleNode implements INodeType {
|
||||||
// Iterates over all input items and add the key "myString" with the
|
// Iterates over all input items and add the key "myString" with the
|
||||||
// value the parameter "myString" resolves to.
|
// value the parameter "myString" resolves to.
|
||||||
// (This could be a different value for each item in case it contains an expression)
|
// (This could be a different value for each item in case it contains an expression)
|
||||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
for (let itemIndex = 0; itemIndex < itemCount; itemIndex++) {
|
||||||
try {
|
try {
|
||||||
myString = this.getNodeParameter('myString', itemIndex, '') as string;
|
myString = this.getNodeParameter('myString', itemIndex, '') as string;
|
||||||
item = items[itemIndex];
|
item = items[itemIndex];
|
||||||
|
|
@ -56,7 +57,7 @@ export class ExampleNode implements INodeType {
|
||||||
// This node should never fail but we want to showcase how
|
// This node should never fail but we want to showcase how
|
||||||
// to handle errors.
|
// to handle errors.
|
||||||
if (this.continueOnFail()) {
|
if (this.continueOnFail()) {
|
||||||
items.push({ json: this.getInputData(itemIndex)[0].json, error, pairedItem: itemIndex });
|
items[itemIndex].error = error;
|
||||||
} else {
|
} else {
|
||||||
// Adding `itemIndex` allows other workflows to handle this error
|
// Adding `itemIndex` allows other workflows to handle this error
|
||||||
if (error.context) {
|
if (error.context) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue