Postman Scripts

PHOTO EMBED

Fri Apr 04 2025 08:10:06 GMT+0000 (Coordinated Universal Time)

Saved by @StephenThevar

---------- set bearer token-----------
const token = pm.environment.get("TOKEN");

console.log(token)

if (!token) {
    console.error("Token is not set in the environment.");
    throw new Error("Token is missing. Please set the token in the environment.");
}

pm.request.headers.add({
    key: "Authorization",
    value: `Bearer ${token}`
});
content_copyCOPY

script for vscode postman