You need to use an IF statement.
Similar to the following…
const response = pm.response.json(); // parse response
let standardFunction = response._embedded[0].standardFunction // define this as a variable so the IF statement is easier to read
if ("value" in standardFunction) { // does the value 'key' exist?
valuestandardFunction = standardFunction.value;
} else {
valuestandardFunction = standardFunction;
}
console.log ("value of standardFunction:" + valuestandardFunction)
pm.environment.set("standaardfunctie", valuestandardFunction);
On a side note, you don’t appear to have any actual tests\assertions in your current code. (pm.test and pm.expect blocks).
Now although that will probably work for you. My recommendation is that you don’t have IF statements like this.
You need to be in control of your test data and it should return the same response each and every time.
This should be two specific requests to the same API endpoint. With appropriate tests for existence of value and the second request checking that it doesn’t exist.