0
votes

I'm trying to store a postman collection variable for a JWT token after a user logins. I am getting this error:

SyntaxError | Invalid or unexpected token

For reference this is what I've been using for the tests

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

response from POST on user login

{
    "success": true,
    "token": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVjYjRhN2E0Njg5MzBiN2FkOTI0MzUwZCIsIm5hbWUiOiJWaW5jZW50IFRhbmciLCJpYXQiOjE1NTUzNzEzMDYsImV4cCI6MTU1NTM3NDkwNn0.P3V2YRcAAkZugJnCZ-GYFcCqFHDn4ei45kh5MgO2r0s"
}

Picture of POST request for user to login

enter image description here

1

1 Answers

0
votes

Okay I figured out the solution.

I copied the snippet from a blog but the blog rendered the quotations as Unicode characters instead of just regular quotes.

Original statement:

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

Revised:

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