I'm posting data to a restify API, but cannot find any currently examples for how to access the posted data. How does this work?
restify is a node. js module built specifically to enable you to build correct REST web services. It intentionally borrows heavily from express as that is more or less the de facto API for writing web applications on top of node. js.
A Node. js web service framework optimized for building semantically correct RESTful web services ready for production use at scale. restify optimizes for introspection and performance, and is used in some of the largest Node. js deployments on Earth.
I found the answer. One of the included plugins needs to be activated, restify.bodyParser
. The data may then be found in either req.params
(default) or req.body
(mapParams: false
), depending on the settings (look specifically at BodyParser section).
Example:
server.use(restify.bodyParser({ mapParams: false })); // mapped in req.body
Or:
server.use(restify.bodyParser()); // mapped in req.params
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With