Reputation: 2800
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?
Upvotes: 0
Views: 388
Reputation: 2813
Notice the difference between "
and “
pm.environment.set(“token”, data.token);
should look like this
pm.environment.set("token", data.token);
Upvotes: 2