How to get data from webhook in Function

My webhook has the follwoing data:

[
    {
        "body": {
            "Checklist": {
               ...
                "Metadata": {
                    "Situation": "Emergency"
                }
            },
            ...
        }       
    }
]

I like to access the Situation value in my Function (action) but I do not get it to work. What I have tried:

const situation= $node["Webhook"].data["body"]["Checklist"]["Metadata"]["Situation"];
const situation= items[0].json.["body"]["Checklist"]["Metadata"]["Situation"];

image

Sorry I think there was another problem in my script that broke the logic. But is there a way to debug the script? See what value I actually get out of the situation constant?
Because when I return the situation const I don’t get any value out:

return situation;

This works, but why?

const newItems = [];
newItems.push({
    json: {
      "situation": situation
    }
  });
return newItems

The Function-Node expects an array of items. And each item has to contain a “json” property. That is why the above example works and the other one not.

You can find some information about the Function-Node here:

and about the data structure in general here: