Hi,
Thanks a lot for the prompt answer, that gave me the clue to go look into postReceive.
I’ve done it a bit differently, where I define postReceive: [sendErrorPostReceive]
I’ve done it like that:
export async function sendErrorPostReceive(
this: IExecuteSingleFunctions,
data: INodeExecutionData[],
response: IN8nHttpFullResponse,
): Promise<INodeExecutionData[]> {
if(response.statusCode === 200)
{return data;}
else
{throw new NodeApiError(
this.getNode(),
{},
{
message: 'Sending failed',
description:
'test',
httpCode: '500',
},
);
}
}
If it’s all fine, I return data, and that works fine, if not, I throw a NodeApiError. That seemed to work just fine, and when I test the NodeApiError (by ignoring the if), it works.
However, when I run my node and do an error on purpose, I still get the same answer as before (as in my initial message), as if the “postReceive” wasn’t even called. Is that possible ? Should I change a parameter to force it’s execution ?
Here’s the setup:
{ name: 'GET - Find Item',
value: 'finditem',
action: 'Perform a GET request',
routing: {
request: {
method: 'GET',
url: '=/item/{{$parameter.id}}',
returnFullResponse: true,
},
output: {
postReceive: [sendErrorPostReceive],
},
},
}
Thanks in advance !
Best,
Alex