I'm making a postman call to an endpoint and i want to save in a variable only a number from my response body's field.
POST {{baseURL}}/{{version}}/{{customersEndpoint}}
response:
{
"firstName": "te",
"lastName": "test",
"customerUrl": "/api/v1/customers/172"
}
var response = JSON.parse(responseBody)
console.log(response)
console.log(response.customerUrl)
I want to save in a variable only the number 172.
var customerID = response.customerUrl(something) ???
Thanks!
response.customerUrl.match("\/[0-9]+")[0]
. It gives "/172", actually, but you can modify it further yourself.