Automatically add decimal placements in WeWeb?

I have an API from Xano that returns prices for products as a decimal field. Here is a sample list:

  • 229.99
  • 199.98
  • 349
  • 522.87

On the front-end, I would like all of the prices to be displayed in the same decimal format, meaning that the 349 value should be displayed as 349.00.

In Bubble I could just select the value output as a currency and then add a decimal place of “2” and it formatted it all perfectly. But I can’t figure out a formula in WeWeb to accomplish this. Is this possible or will I need to take care of the formatting on the Xano side?

image

BONUS QUESTION: Is it also possible for WeWeb to separate thousands by a comma?

1999

Becomes

1,999

If you’re going to do it in more than 1 place, I’d create a formula that takes the numeric input and spits out a string representation of the numeric value.

I’d most likely be using a js manipulation in the formula

I solved this using co-pilot which created some custom JS for me. I couldn’t figure out a no-code way to do it.

1 Like