Replacing API text with database value

I am trying to figure out how to do this with Wappler. I have codes returning from an api feed. I want to replace the code with the actual name which I have in a separate database. Where api code == database code. Can you point me in the right direction?


Any word on this?

thank you

Can you give way more detail on what you are trying to do, I could not really understand what you trying.

So I have an api which returns a state code. Say NY. I have a mysql database which has state codes and state names. example NY and New York. I would like to replace the NY from the api with New York from the mysql database.

Ahh ok that makes sense, a few questions.

  1. Are you calling in the state data from the API on the server side or client side?
  2. Are you only needing to retrieve one state code at a time or a list of all of them.

Basically though it should be pretty simple, assuming you are using something like a dropdown select with a list of states, you could have a server action getting all the state codes from the API and another server action getting all the state codes from the database, Possibly even a single server action if you prefer.

Then add a dynamic select and use a where data formatter to compare your database results with the API results which will return the correct name for the code.

If you are just wanting to replace NY with New York in various areas of text in your document you can do a similar thing with the where data formatters.

I will try give more definitive info when i know how you are using the data and getting the data server side vs client side API calls.

I am getting from the server side. So both the api state codes and the mysql State names are coming from server connect. It would be the same as a mysql join if they were both mysql tables. Hope I am explaining that correctly.

Yeah would make it far simpler if you could just use a mysql join.

I would try doing a server action with an API Action calling all the state codes, then using that as the expression for a repeat.
In the repeat use a single database query and filter the data by the state code from the repeat.

Then calling in the data Client side you could just use a repeat region to repeat through all records of the database query from the server actions’ repeat.

Hope that sort of makes sense.

EDIT: Easiest way is after the server action is created and tested using the open in browser command from server connect, then use the built in Wappler Bootstrap Table Generator which will add all the repeats etc a needed and then just adjust it to suit your needs.

Yes a join would be way easier. Unfortunately the api only returns the codes. (This is true for many other fields as well). Thanks I will try that.

Cool if you get stuck, send some screenshots of where you are at in the process and we will try assist, although now that your question is a little clearer to understand you may find a few others might have some different ideas for you too.

OK here is a more complex version. I get all the flights from the api fine. The airline carrierCode is nested into segments. The AirlineNames are in a mysql database. I would like to output the airline name as well. Not sure if this is the right approach or not.

Here are some screenshots if you can help. Doesn’t seem like it should be that complicated but I just cannot make it work.

Besides your PM I also made a guide for the others.