0
votes

In tests section, I try to set token as Postman variable. I get the following error:

SyntaxError: Invalid or unexpected token

Here's my script in test tab:

var data = pm.response.json();
pm.environment.set(“token”, data.token);

and here's my response for login:

{
"id": 1,
"username": "admin",
"name": "John",
"token": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTU2OTY3ODg4NSwiaWF0IjoxNTY5MDc0MDg1fQ.k6aMQYo9uzC9jEXFvP1EZEUNEG_7VgEKxKmNtrZ9rSYvViHCNGYMaEpYY7MH8rYgtIg1Lpi4bfZEd9q2iOEOSQ"
}

Content type of response is application/json;charset=UTF-8.

What am I missing?

1

1 Answers

2
votes

Notice the difference between " and

pm.environment.set(“token”, data.token);

should look like this

pm.environment.set("token", data.token);

enter image description here