You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a plugin of the serverless framework, it provides the extra CLI option --body/-b for the invoke (local) command
to support passing the HTTP body data directly.
Currently(serverless@1.32.0), The serverless framework providing the --data and --path options for the invoke command to passing the event data to the handler functions.
However, we have to use the string formatted(instead of JSON) HTTP body data for the value of body field in the JSON formatted event data.
which means that we have to escape the quotes for the actually JSON based body data.
e.g:
{"body": "{\"body_key\": \"body_value\"}"}
That makes the body data unreadable and unmanageable, especially for the complicated body data.
This plugin helped that!
with it, we can specify the JSON formatted HTTP body data in the CLI directly instead of wrapping them in the event.
Installation
Performing npm install at the root path of your service.
$ npm install --save serverless-event-body-option
Adding the plugin to your serverless.yml file.
plugins:
- serverless-event-body-option
Usage
Invoking the function
Specifying the data from stdin directly if the data is short.