How can I copy a non Json text response to a Variable in the tests

How can I copy a non Json response to a Variable in the tests
I have just done it to the console to see if I can get the info to at least show there

I have tried a lot of different ways a few of the json.parse but I then get a JSON error

JSONError: Unexpected token ā€˜eā€™ at 1:1 or ā€œundefinedā€ for the non JSON ways

How I found the problem
Run a request and then tried to copy the body of the response (which is a token) to a environment variable.

Iā€™ve already tried:
I have looked around on different ways (most are for JSON)
On how to do this but they all come back with an error or with ā€œundefinedā€

1 Like

Hey @fenwickr

To get the value of a non JSON response, you would use pm.response.text().

Once you have that you that, you can use some basic JS to extract different parts of the value if needed.

1 Like

Thanks work perfectly - When I tried that I was missing the () after the text

1 Like