I am running a chain of collections from 1 API call to another. I want to pull the response body from API call 1 to API call 2 so that it can post the data to my application.
I have created the environment variables and in the tests tab I have created a script to set the variables but when I run the script I get a response of the below:
SyntaxError: Unexpected token [
My test script is:
bodyData = JSON.parse(responseBody)
value = bodyData.[1]country
console.log(value)
The response body looks like this
[
{
"Country": "United Kingdom",
}
]
I know the issue is [] and needs to have a string before it but the API is not defined with a string and I cant just use the below as it's then undefined:
bodyData = JSON.parse(responseBody)
value = bodyData.country
console.log(value)
Any idea how I can get this to work?