Question:
I’m trying to create a Velo post method that does a fetch with the body of the post request. In the backend Wix Editor I created this method that works fine when I run it from the editor but when I call it as a post it doesn’t work. I’ve tried other ways but can’t get it to work.
Please show me sample code that does a fetch with the body of the post request.
I’m primarily interested in doing this on a backend post I would also like to know if there is anyway to do logging on backend post or get requests. It has been hard to debug this.
Here is an example of a backend get request handler that works. I can take the values of URL query variables and uses them in my fetch. I just want to equivalent code in a post request handler.
So the only issue with the original code was when it was making the post request, not the code handling the post request.
The original fetchOptions was this which didn’t work:
As for logging yes you can do that. console.log and console.error will print to your site logs when used on the backend. You can either use Wix’s builtin logging that only records and displays logs when you have the log page open, or you can use external providers like Google Operations to get persistent logs. More info on this here: About Logs (formerly Site Monitoring)