WEB API Test/Postman

VARIABLES 활용

정신차려이각박한세상속에서 2020. 8. 6. 15:16

사전 설정

settings 화면

 

 

How to get & set variables through scripts

[Test 탭 스크립트 작성]
[Pre-request Scripts 탭 스크립트 작성]

console.log("Hello world..."); 

let urlVar = pm.variables.get("url");
console.log("Value for url variables is : "+urlVar);

pm.variables.set("name", "POSTMAN");

console.log(pm.variables.get("name"));

let globalVar = pm.globals.get("Env");

console.log(globalVar);

 

관련 스크립트 방법은 아래 URL 참고

https://learning.postman.com/docs/writing-scripts/script-references/test-examples/

 

Home

Postman Learning Center Learn how to use Postman effectively in your API projects. Check out the docs and support resources! Explore the docs

learning.postman.com

 

 

실행 후 콘솔 화면