When I type the script into the pre-request script tab then show this message:
there was an error evaluating the pre-request script pm is not defined
My script is:
let tokenUrl = '****/connect/token';
let clientId = " ****";
let clientSecret = ' ****';
let getTokenRequest = {
method: 'POST',
url: tokenUrl,
auth: {
type: "basic",
basic: [
{ key: "username", value: clientId },
{ key: "password", value: clientSecret }
]
},
body: {
mode: 'formdata',
formdata: [
{ key: 'grant_type', value: 'client_credentials' }
]
}
};
pm.sendRequest(getTokenRequest, (err, response) => {
let newAccessToken = response.json().access_token;
pm.environment.set('accessToken', newAccessToken);
pm.variables.set('accessToken', newAccessToken);
});
How to or where use my code? Please help me.