Hi,
I am using a “Code in JavaScript” node to convert a JSON file received via a webhook, which is then used by a subsequent HTTP request node. The problem is that sometimes I receive a line from the webhook like "reason": "550-5.1.1 user unknown\n 550 5.1.1 Unknown recipient.", and this causes an issue in the following node. I’ve tried to fix it using the “Code in JavaScript” node with this code:
reason: $json.body.reason ? $json.body.reason.replace(/\n/g, " ") // Replaces actual line breaks with spaces
.replace(/\\n/g, " ") // Replaces escape sequences \\n with spaces
: "",
However, the output remains unchanged. How can I fix this?