Probably my worst question yet - I cannot get my server connect form to input data into my DB

Hi all,

Little embarrassed to ask this one.

I’ve created a server action:

  1. Database Connection
  2. imported the form using globals to ensure I get the correct parameters.
  3. Database Insert action using encryption for the password and making sure the form post parameters are all as per those that where imported.

and then saved it. All working fine, connecting to the DB.

Then on the app connect side, I have converted the form to server connect and selected the correct ‘register_user’ server action.

I’ve added a couple of on success actions such as a notification and also a redirect.

I then push to dev on Heroku, and also test on my local machine - the form just doesn’t send data to the DB. I’m at a bit of a loss, I’ve read all information in documentation and read through the forum - there is very little regarding this, I’m assuming as I’m just missing something super simple.

Any/All help appreciated.

Are you using the browser console to confirm the data is in fact being sent, and what it is sending?

I hadn’t, but I’ve just done that and the console returned “POST http://localhost:3000/api/security/register_user 500 (Internal Server Error)”

Okay, let’s start here:

And also, take a look at the call from the client to back end.

Here’s an example. Go to the network tab, and find the server connect item (I usually filter by XHR). Then click on it to see the preview (for the error) and the Headers (to see what is actually being sent.

Thanks Ken, I’ve followed the steps and this is the return. Looks like something to do with the standard increment ID field? I have not touched than, and just left it with increment. Do you see that as the same issue?

{status: “500”, code: “22001”,…}
code: “22001”
message: “insert into “users” (“created_at_”, “email”, “firstName”, “lastName”, “modified_at_”, “password”) values ($1, $2, $3, $4, $5, $6) returning “id” - value too long for type character varying(125)”
stack: “error: insert into “users” (“created_at_”, “email”, “firstName”, “lastName”, “modified_at_”, “password”) values ($1, $2, $3, $4, $5, $6) returning “id” - value too long for type character varying(125)↵ at Parser.parseErrorMessage (/Users/Matt/Documents/Wappler/pitchflare_new/node_modules/pg-protocol/dist/parser.js:278:15)↵ at Parser.handlePacket (/Users/Matt/Documents/Wappler/pitchflare_new/node_modules/pg-protocol/dist/parser.js:126:29)↵ at Parser.parse (/Users/Matt/Documents/Wappler/pitchflare_new/node_modules/pg-protocol/dist/parser.js:39:38)↵ at TLSSocket. (/Users/Matt/Documents/Wappler/pitchflare_new/node_modules/pg-protocol/dist/index.js:8:42)↵ at TLSSocket.emit (events.js:315:20)↵ at addChunk (_stream_readable.js:302:12)↵ at readableAddChunk (_stream_readable.js:278:9)↵ at TLSSocket.Readable.push (_stream_readable.js:217:10)↵ at TLSWrap.onStreamRead (internal/stream_base_commons.js:186:23)”
status: “500”

Noting that I didn’t even have ID in the input fields, as I assumed it would assign and accumulate by default?

Any thoughts on what ‘stack’ is? It seems to be sending data from a older project/version

Correct, the auto increment should not be added… the db does that for you.

It looks like you are trying to insert a value that is too long for the field.

Your input fields need both the I’d and the name. Then you have to bind them in your insert action.

I’m not at my computer otherwise I would provide screenshots

as this is a registration form, how can I include an ID as the user won’t have one yet - relying on Wappler to input this?

I’ve gone back through and put validations on each field related to the length, but as I was only testing there was very little data going into the fields, so it shouldn’t have been that.

I must be doing something basic wrong, I’ve just loaded another page that has a form (my plan was to test a different form) - and these errors displayed regarding two server connects I’ve setup.

The DB is connected and pulls in the schema (noting something odd is happening, I can’t seem to update timestamp fields).

If you are hashing the password, it might be the culprit.

For these errors, remember that you may have security constraints in place that require login

1 Like

This fixed it!! thank you. Now getting a 200 on the submit. I reduced the hashing to a lower count. What’s weird now however, is that I’m not able to execute any server connect success actions - in the console there are no properties displayed as sent and no response either (just curly brackets for both) - which I assume there needs to be a response for the app to know to do X.

Thank you - I thought that might have been the case just didn’t expect the error within Wappler itself, as it’ll always throw that error if this is the case.