Environment variables from pm.response body

Hi dear team. I’m completely new to the Postman, I’m learning it)
So i have a task to do environment variable from the response body.
The issue is in request body i set:
“email”: “{{$randomEmail}}”

In Test i set environment variable as:
pm.environment.set(“emailvariable”, “pm.response.json().user.email”);

after running in my env variables i don’t see email from response, but have a script…
What is wrong?

Screenshoots:

Hi @Yuliia

You need to remove the quotes from the value part of the environment set.
(If you use quotes here you are passing the value as a string… but you want to refer to a value within your response).

Try this;
pm.environment.set(“emailvariable”, pm.response.json().user.email);