Hello Alex,
Before i test your example code for form submission, i am stuck with the API call, i have created a file server/api/index.js and here its code part
import express from 'express' import pkg from '@prisma/client'; const { PrismaClient } = pkg; const prisma = new PrismaClient({ log: ['query'] }) const app = express() // Body parser, to access `req.body` app.use(express.json()) app.get('/apitest', async (req, res) => { res.end('Test API!') }) app.post('/sendMessage', async (req, res) => { const { name, email, company_name, phone, message } = req.body const post = await prisma.contact.create({ data: { name, email, company_name, phone, message } }) res.status(200).json(post) })
Now, when i run the server localhost:3000 it says handle is not a function with error code 500
i think as per nuxt 3 document for API ( v3.nuxtjs.org/docs/directory-struc... ) might be it has its own way to handle the request,
So, did you have ever tried this kind of call and have any suggestion for me to fix it?
Thanks a lot
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hello Alex,
Before i test your example code for form submission, i am stuck with the API call, i have created a file server/api/index.js and here its code part
Now, when i run the server localhost:3000 it says handle is not a function
with error code 500
i think as per nuxt 3 document for API ( v3.nuxtjs.org/docs/directory-struc... ) might be it has its own way to handle the request,
So, did you have ever tried this kind of call and have any suggestion for me to fix it?
Thanks a lot