The routes set using the UI in Wappler are only for GET, if you want to set a DELETE route you have to edit the routes.json directly, it is located in app/config/routes.json. Find the route you created in the JSON and add an extra property to it "method": "delete".
Perhaps we could change the default to accept all methods or add an option to the UI to allow you set the method for the route, which is probably preferred if you are creating a rest api.
@patrick am I able to add multiple methods? If so, how?
Adding delete worked, so it appears GET, POST, and DELETE are now working, but PATCH is not.
Also, if I add patch instead of delete, then I get this error.
"status": "500",
"message": "Empty .update() call detected! Update data does not contain any values to update. This will result in a faulty query. Table: Contact. Columns: Account,FirstName,LastName,Company,isPinned,VIP,Email.",
"stack": "Error: Empty .update() call detected! Update data does not contain any values to update. This will result in a faulty query. Table: Contact. Columns: Account,FirstName,LastName,Company,isPinned,VIP,Email.\n at QueryCompiler_MySQL._prepUpdate (/opt/node_app/node_modules/knex/lib/query/compiler.js:819:13)\n at QueryCompiler_MySQL.update (/opt/node_app/node_modules/knex/lib/dialects/mysql/query/compiler.js:59:26)\n at QueryCompiler_MySQL.toSQL (/opt/node_app/node_modules/knex/lib/query/compiler.js:61:29)\n at Builder.toSQL (/opt/node_app/node_modules/knex/lib/query/builder.js:97:44)\n at /opt/node_app/node_modules/knex/lib/runner.js:31:36\n at /opt/node_app/node_modules/knex/lib/runner.js:277:24\n at processTicksAndRejections (internal/process/task_queues.js:97:5)\n at async App.update (/opt/node_app/lib/modules/dbupdater.js:54:24)\n at async App._exec (/opt/node_app/lib/core/app.js:425:30)\n at async App._exec (/opt/node_app/lib/core/app.js:396:17)"
I’m attempting to pass json key:value pairs in the body. I realize this doesn’t follow RFC 5789 or RFC 6902, but it should suffice for sending what I need.
@patrick, I figured it out -- although, in order to get the update to work, I had to add a duplicate route for each -- except the PATCH method still doesn't work.
I can use POST to update, but I would prefer to use PATCH.
If you use the same action for all the methods you could just use all as method, that would catch all the different methods. We will make that the default for the next update instead of get.
My preference would be to have the option to pick multiple methods for a route – not just one. Also there’s a lot of methods and not all may be valid, or desired, for a route specific route.