I'm new to writing pre-request script and tests in Postman. So, I wonder if there's possible to make show the value from response body when the tests fail.
This is the example of the error response body and I want the test result to "FAIL" and show the value from "errorReason" in the test results tab.
{
"errors": [
{
"errorCode": 401,
"errorReason": "BALANCE_BELOW_ZERO"
}
]
}
I using this way to get error message from api
async getSomething() {
try {
let response = await axios.get(
`API/getSomething`
);
let data = response.data;
htmlElememt.innerHTML = data
} catch (e) {
// according to your error response
alert(e.response.errors.errorReason);
}