Postman is sabotaging me!

Postman is sabotaging me!
0

Hi i’m testing a bunch of express endpoints using Postman. For my signup and login routes i use the following test scritpt

if(pm.response.status === 'OK'){
    pm.globals.set('x-access-token', pm.response.json().data.token);
}

however it only seems to work on the login route, And neither works when i set the variable using
pm.environment.set
method.
Please help