'Parsing nested JSON from aws SNS message
I'm having trouble returning errorMessage from this nested JSON response I get from an aws SNS message. Part of the problem, I think, is the weird spaces and formatting this is returned in. I parsed the whole thing once to get message which I'm able to return values like executionIdfrom, but JSON.parse(message.errorData) already throws me an error before I can continue downward to -> Cause -> errorMessage.
{"executionId":"<<ARN REDACTED>>","stateName":"9b44bafc-d542-4533-8091-5c9a2bfd9983","startTime":"2022-04-07T16:20:59.350Z","sourceStepFunction":"<<REDACTED>>","errorData":{"Error":"Error","Cause":"{\"errorType\":\"Error\",\"errorMessage\":\"Request failed with status code 400\",\"trace\":[\"Error: Request failed with status code 400\",\" at e.exports (/var/task/index.js:2:69443)\",\" at e.exports (/var/task/index.js:2:71859)\",\" at IncomingMessage.<anonymous> (/var/task/index.js:2:62409)\",\" at IncomingMessage.emit (events.js:412:35)\",\" at IncomingMessage.emit (domain.js:475:12)\",\" at endReadableNT (internal/streams/readable.js:1334:12)\",\" at processTicksAndRejections (internal/process/task_queues.js:82:21)\"]}"}}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
