Append suffix to integer value inside object array

Options

Hi community,

I'm currently working on this workout logger app, where frontend sends repetitions and weight values in the form of integer to Xano.

The issue I'm having is, that I would like to add a measurement unit suffix to the weight value received from the frontend. Ex.:

  1. Frontend send to Xano: 99.
  2. Xano returns to frontend: "99 kg".

For more context, I currently have this GET endpoint which contains the values of all exercises in the form of an object array…

Is there any way to update each one of the weight values per each exercise inside the object array?

Thanks for the help,

Best Answers

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Answer ✓
    Options

    Yes you can - its a little involved because you'll need to

    1) pull your keys into an array,

    2) iterate over your key list, (following is inside that for-each)

    3) get the member at that path

    4), update the sub-key with the suffix likely using to_text and then concat filters, and then

    5) re-attach the member to your source object.

    After this loop, your data shoudl have the suffix in place!

    Not simple - but you do it once and it keeps working. Completely do-able!

  • fdoolivares
    fdoolivares Member
    Answer ✓
    Options

    Thanks @Ray Deck , will give it a try.