N
Nuxt8mo ago
83inc

Amateur Looking for Help Making POST to MySQL Using Nuxt 3

I come from a heavy product management, design and marketing background and have recently been able to brute-force my way through creating a simple form page using Nuxt 3/Vue 3/Tailwind/Pinia with Vercel for deployment and just set up a Digital Ocean MySQL database. I've managed to accomplish a lot and I absolutely love everything about Nuxt/Vue and coming from a Figma background, Tailwind was especially fast to learn. I've got Pinia working but am now stuck on getting that data into my new DB. So the flow is:User lands on my Form0001.vue form component. The userStore.js Pinia store is initialized and the useHandleVisitor.js composable is imported. (See attachment for code.) This create a UUID which im using as the primary key in the MySQL table. Now, as the user fills out the form, the SaveVisitorData function is sending this data to the save-visitor-data.js endpoint in server/api. (See attachment for code.) The issue is that I can see the endpoint being called in network. I see a 200 code, but the response is: {success: false, error: "Cannot convert object to primitive value",…} error: "Cannot convert object to primitive value" stack: "Error: Cannot convert object to primitive value\n at PromisePool.query success: false I can't seem to figure this one out. Any ideas one what I'm doing wrong?
1 Reply
Mads
Mads8mo ago
Would you be able to post it as a Gist or just add the code in here? But from just reading your post I would assume your connection to the Nitro backend is fine and gets called when you want it to. It seems like the data it receives could be wrong. I would debug here first, throw in some console logs to see what it catches. Does it receive your body data? If it does, onto next issue. Other than that, I would highly recommend Drizzle or Prisma as it would give you some better error logs on what goes wrong.
Want results from more Discord servers?
Add your server