问题
I am using postman to get response header value like below:
var data = postman.getResponseHeader("Location") . //value is "http://aaa/bbb" for example
I can print the value via console.log(data)
easily.
However, what I really want is "bbb". So I need some substring()
type of function. And apparently 'data' is not a javascript string type, because data.substring(10)
for example always return null.
Does anyone what i need to do in this case?
If any postman API doc existing that explains this?
回答1:
You can set an environment variable in postman. try something like
var data = JSON.parse(postman.getResponseHeader("Location"));
postman.setEnvironmentVariable("dataObj", data.href.substring(10));
来源:https://stackoverflow.com/questions/54085066/in-postman-how-do-i-get-substring-of-response-header-item