2017-09-22 27 views
1

對於我的POST請求,在響應頭像我得到1 < location: /users/123 我想打印只有id> 123. 當我在我的功能文件中做* print responseHeaders['location'][0],我得到users/123。我如何才能得到唯一的ID?如何在responseHeaders位置獲取id?

回答

1

這是不是一個真正的空手道的問題是:P

試試這個:

* def location = responseHeaders['location'][0] 
* def userId = location.substring(location.lastIndexOf('/') + 1) 
* print userId 

這是正確的,JavaScript的(或通過Java interop連渣)的所有功能是提供給您的空手道!

+1

感謝它的工作。我會盡量在我的功能中使用更好的js – nirind