By default, cURL uses Content-Type: application/x-www-form-urlencoded
for form submissions that do not contain files.
For forms with urlencoded, your data must be in the correct format: curl -X POST -d 'foo=bar&baz=bla' http://127.0.0.1:3000/module
or curl -X POST -d 'foo=bar' -d 'baz=bla' http://127.0.0.1:3000/module
.
For JSON, you need to explicitly set the correct Content-Type
: curl -H "Content-Type: application/json" -d '{"foo":"bar","baz":"bla"}' http://127.0.0.1:3000/module
.
Also, as @Brett pointed out, you need app.use()
your middleware to this POST route somewhere (outside the route handler).
source share