Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Extract Variables Policy with JSON payload type string but cannot manipulate in node

Not applicable

The request has a payload like:

{"books": ["a", "b", "c"]} and I store it into the variable "myBooks" using an Extract Variables Policy

In node.js I use apigee-access to get the extracted variable:

var myNodeBooks = apigee.getVariable(req, 'myBooks');

console.log(myNodeBooks) gives what you'd expect:

["a","b","c"]

However, I can't operate on the variable at all.

myNodeBooks[0] breaks at runtime. So does myNodeBooks.split(","). If I send a request to BaaS with the variable, BaaS just ignores it.

My suspicion is it's a problem with the data type but I'm hoping someone with my experience could clarify.

Thanks.

0 4 1,407
4 REPLIES 4