refactor(core): fix for no-uncaught-json-parse warnings

This commit is contained in:
Michael Kret
2022-10-21 21:52:43 +03:00
committed by GitHub
parent ca9eca9ae9
commit 1d57b10942
36 changed files with 150 additions and 93 deletions

View File

@@ -7,6 +7,7 @@ import {
INodeExecutionData,
INodeType,
INodeTypeDescription,
jsonParse,
NodeOperationError,
} from 'n8n-workflow';
@@ -206,7 +207,9 @@ export class RespondToWebhook implements INodeType {
if (respondWith === 'json') {
const responseBodyParameter = this.getNodeParameter('responseBody', 0) as string;
if (responseBodyParameter) {
responseBody = JSON.parse(responseBodyParameter);
responseBody = jsonParse(responseBodyParameter, {
errorMessage: "Invalid JSON in 'Response Body' field",
});
}
} else if (respondWith === 'firstIncomingItem') {
responseBody = items[0].json;