07-02-2022 08:09 PM
I am using UNION snap to get input streams from 2 snaps. Next to the UNION snap, I have a MAPPER snap that tries to access the output stream of UNION snap.
Please see attached screenshot.
I can see the parameter $response.entity.token but snap keeps erroring saying that there is no such $response parameter. Could you please guide me on this? I have already spent 6 hours trying to debug this issue.
07-03-2022 06:02 AM
That is happening because the output of the Union Snap will produce multiple documents(from both inputs). And some of the documents does not contains the value that you are referring to, which throws an error.
By checking the “null safe acess” in the mapper snap will prevent the error, and on the output of the mapper snap you will have the same number of documents as input. The documents that does not contains the path that you are referring will have “null” value on output.
BR,
Spiro Taleski
07-25-2022 08:39 AM
Thank you, Spiro
07-25-2022 11:57 AM
I think as an alternative to using the null safe access feature, you could also use the hasPath() and get() methods. I like using the get() a little more because if the path doesn’t exist, then it will automatically assign a null to the result of the expression, whereas the hasPath() method renders a true or false result. If you use hasPath(), then you’ll probably want to incorporate it as part of a ternary expression.
Here’s a few conceptual examples for you.