Complete the code to access the global variable in Postman test script.
pm.globals.set('token', 'abc123'); const tokenValue = pm.[1].get('token');
The pm.globals object is used to access global variables in Postman scripts.
Complete the code to set an environment variable in Postman test script.
pm.[1].set('userId', 'user_001');
Environment variables are set using pm.environment.set() in Postman scripts.
Fix the error in the code to correctly get a collection variable in Postman test script.
const apiKey = pm.[1].get('api_key');
Collection variables are accessed with pm.collectionVariables.get() in Postman.
Fill both blanks to correctly set and then get a local variable in Postman test script.
pm.variables.[1]('sessionId', 'sess_789'); const session = pm.variables.[2]('sessionId');
Local variables in Postman are set with pm.variables.set() and accessed with pm.variables.get().
Fill all three blanks to create a test that checks if the environment variable 'status' equals 'active'.
const status = pm.[1].get('status'); pm.test('Status is active', function () { pm.expect(status).to.[2]([3]); });
The environment variable 'status' is accessed with pm.environment.get(). The test uses pm.expect().to.equal() to check the value against the string 'active'.