In POSTMAN how do i get substring of response header item?

喜欢而已 提交于 2019-12-11 02:27:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!