HTML form POST data body is empty

So i have a simple iFrame with this form:

Submit

And I have a simple server side function in http-functions.js:

export async function use_myFunction(req)
{
let bodyresp = await req.body
let options = {
“headers”: {
“Content-Type”: “application/json”
},
“body” :{
“response”: bodyresp
}
}
return ok(options);
}

But the body is always empty. I have tried to POST data using postman and I still get an empty body as response. What am I doing wrong?

#https #post api

I have the same issue! :frowning:

Unable to help unless you provide more information. What are you trying to accomplish? Post your code here in a code block. What works? What doesn’t?

Try to consume the body in JSON format:

let bodyresp = await req.body.json()
console.log(req) to debug. Preview the site and call the post to:

https://mysite.wixsite.com/mysite/_functions-dev/myFunction "

the _function-dev shows the console.log on previewing the site.
You need to publish.

I had some CORS issues. Try this :

“headers” : {
“Content-Type” : “application/json” ,
“Access-Control-Allow-Origin” : “*”
}