Discover more from Xanomorph
Force Xano to treat an array as one, rather than a string, when calling an external API
Lamest workaround ever.
Ensuring Xano correctly identifies the data type (string, integer, array) of inputs and variables is important to making things work as expected.
There is already a very long community thread about how to take a string input containing integers in an array and have Xano treat them as an array, rather than a string.
This is just one side of the problem, however, because it doesn’t address how to handle this issue when calling an external API; it only addresses when Xano is the API being called.
An example where this is important is when making calls to the OpenAI GPT-3.5/4 API. In my use case, I use a system message instructing the model to return the results as an array. It does this, but from Xano’s perspective, the response is a string:
This is problematic if you have subsequent logic that needs to use this as an actual array.
Fortunately, I found a very simple, but lame, workaround: just create a Lambda function that returns the variable in question:
Thanks for reading Xanomorph! Subscribe for free to receive new posts and support my work.