Mobile App DB Connection

Hi Wappler Community,

I have a mobile app with a backend API project. I am able to display data from the backend in my mobile app. What I cannot figure out is how to do DB Inserts from my mobile app. From what I understand is that I need a local SQLight DB for my mobile app and that it needs to sync with my backend DB.

Docs are sparse on this subject. So I was hoping someone can point me in the right direction here.

My back end is on Node.js with a Postgres DB.

In this regard mobile apps are no different than web. You create a server connect form that has an API on the server for processing the insert. When choosing the API, make sure to select the applicable project first (upper right corner of the dialog box.)

Yes I am able to do that, the problem Im running into is that in the server actions itself, I am unable to import the post variables from the form in my mobile app. It cannot find the form

I’ve never tried to import a form from a mobile project…but you can try and browse to your mobile project folder and open the file. If it’s coming up empty, you can add your POST inputs manually.

1 Like

You can create the POST variables in the server action by right clicking $_POST and selecting Variable.

Screenshot 2023-06-15 at 22.57.29

2 Likes

Thank you guys! I will give this a try

I am still a little stuck here. So when I hit submit on the form in my mobile app, the web API DB creates the record but does not insert the post variables.

I created the variable in the server action, and set the linked field as the name of the input in the form. (Also tried ID of the input)

I feel like I am missing a step somewhere. I can’t import the form into the server action because the form is in my mobile app.

So I guess the question is, how do I tell the manually created POST variables to take data from the inputs in the mobile app form?

Just to confirm:

On each input in your form you have a id attribute and a name attribute, the name attribute on the input should be the same as the POST variables you created in the server action.

@Sorry_Duh

That is correct. I have a form inside my mobile app. It contains an input with the name input1 (just an example). The form is linked up with a server connect action with my insert server action.

On my backend web app, I have that server action setup to insert the value of input1 into a table called names…again just an example.

Inside that server action, I am unable to set the page the form is on under linked page, therefore I am unable to import from form as the page is on my mobile app, not my backend app.

So I manually created a POST variable named input1

So when I run that action by clicking the submit button on the form, a new record is created on the names table with a new id however their input1 column is empty.

In the dev console you should look at the payload of the server connect. Confirm it is sending the value with the name you expect.

Then in the server api, confirm you are using that same name with $_POST.

Oh my gawd, I am an idiot.

It was as simple as forgetting to set the submit button type to submit. #FACEPALM Total rookie move.

Thank you all for your help. It was you guys that prompted me to look at every part closely.

I wish I had a beer for every time I have done that. :beers:

Glad you got it solved!

:laughing: Absolutely. It’s amazing how often that happens haha.