Hi guys I don’t know how to pass a dynamic value as number to API
As soon as I put double quotes, the api returns error
and if I remove the double quotes the wappler won’t let me save a action
I need to pass a dynamic variable as a number and not as a string
I think the issue is that you have to wrap any value in quotes in the json editor which then makes it a string, even if it started as a number or was even converted to a number. I’ve only ever been able to get around this using a custom formatter to return the correct json structure - would welcome any ideas/suggestions on this
I think this is an issue (more like something that could be improved) in the Wappler UI that requires bound data to be wrapped in quotes in the JSON editor. @george could you take a look?
There is a workaround you could try which is to use a custom formatter.
You would need to write some PHP to take the values as parameters and then make the array structure before returning the array to SC but it shouldn't be too difficult
Use {{plano.valor.toNumber()}}. MySQL returns decimal fields as string since there is no equal type in PHP, converting a decimal to float could cause lost of precision.
But the issue is in the Wappler UI. You can’t add that to a JSON without putting it in " " rendering as a string when sent - the API in this case then rejects it as a string and not a number
But the issue is in the Wappler UI. You can’t add that to a JSON without putting it in " " rendering as a string when sent - the API in this case then rejects it as a string and not a number
When you have "unit_price": "{{plano.valor.toNumber()}}" it will parse the expression in the string and should return the number, not a string. Make sure there the expression is as above, having a space inside it like "{{plano.valor.toNumber()}} " will return a string.