Complete the code to set a variable in a pre-request script.
pm.variables.set('[1]', '12345');
The pre-request script sets the variable userId to prepare data for the request.
Complete the code to get an environment variable in a pre-request script.
const token = pm.environment.get('[1]');
The pre-request script retrieves the authToken from environment variables to use in the request.
Fix the error in the pre-request script to correctly set a header.
pm.request.headers.add({ key: 'Authorization', value: '[1]' });The correct way to get the token value is using pm.environment.get('authToken') to set the header value.
Fill both blanks to prepare a timestamp and set it as a variable.
const timestamp = new Date().[1](); pm.variables.set('requestTime', [2]);
The getTime() method gets the timestamp in milliseconds, stored in timestamp, then set as 'requestTime'.
Fill all three blanks to create a random user ID and set it as an environment variable.
const randomId = Math.[1]() * 1000; pm.environment.set('[2]', randomId.toString()); pm.variables.set('[3]', randomId);
Use Math.random() to generate a random number. Set environment variable 'userId' and local variable 'randomUserId' with this value.