Adding a math equation to an API pull

Good afternoon,

I have a quick general question.

I have an API pull that shows a Calculation. In my case, the amount of carbon emitted. What I would like to do, is once the number is shown in the response field, I would like to multiply that number by the offset amount. Meaning, if there is 13 tonnes of carbon emitted by a person, I would like to have an additional field showcase 13x8.50=110.50. I would like to show just the $110.50.

Thanks for the help

Just add a set value stage after and apply the calculation to the api response.
Check output of course and the value will be returned by the wappler api action response to your page

Thank you for the help @Hyperbytes Just as a note, I am using our backend API call. Would you have any documentation as to how I can accomplish this? I am a little confused.

Nothing ready.

Assuming this is a server side APi call, Its really simple

Your external api call will return a schema, say api.data.co2
Simply add a set value stage after, and use the picker to select api.data.co2 * 8.5
check Output and this will be returned with your wappler API response.
It will be similar to this:

Brian, thank you this is very helpful. one last question, how can I tell it that the output equation is no more that two decimal points?

@Hyperbytes

1 Like

Click on this button

and you will be presented with this dropdown where you can choose between formatting the number or changing it to a currency.

Thank you @ben

@ben I am not using a server side API i am using a form API. Is there still a way to select the item and formate it as currency with only 2 decimal points?

Also, do you know how to create a back button on the form that will allow for the information inputed (i am using the session manager and using show / hide based on items inputed and received by the object) to stay populated in the form field? so that a change can be made?