2.6 KiB
Executable File
Read this on the main serverless docs site
Auth0 Webtasks - Invoke
Invokes a deployed Function. It allows you to send event data to the Function and returns the response.
serverless invoke --function functionName
Options
--functionor-fThe name of the function in your service that you want to invoke. Required.--stageor-sThe stage in your service that you want to deploy to. The default stage is 'dev'.--profileor-pThe Auth0 Webtasks profile to use when deploying your service. The 'serverless' profile is used by default.--dataor-dString data to be passed as an event to your function. By default data is read from standard input.--pathor-pThe path to a JSON file with input data to be passed to the invoked function. This path is relative to the root directory of the service.
Provided lifecycle events
invoke:invoke
Examples
Invoking a Function
serverless invoke --function main
This example will invoke the 'main' function for the default 'dev' stage. The webtask will be invoked with an HTTP POST request by default. The command will return the HTTP status code and body of the response.
Invoking a Function with data
serverless invoke --function main --data '{"message":"Serverless + Webtasks!"}'
This example will invoke the 'main' function for the default 'dev' stage. The webtask will be invoked with an HTTP POST and a request body that includes the JSON payload: {"message":"Serverless + Webtasks!"}.
Invoking a Function with specific HTTP method
serverless invoke --function main --data '{"method":"GET", "body":{"message":"Serverless + Webtasks!"}}'
This example will invoke the 'main' function for the default 'dev' stage. The webtask will be invoked with an HTTP GET request and a request body that includes the JSON payload: {"message":"Serverless + Webtasks!"}.
Invoking a Function with a request query string
serverless invoke --function main --data '{"query":{"message":"Serverless + Webtasks!"}}'
This example will invoke the 'main' function for the default 'dev' stage. The webtask will be invoked with an HTTP POST request and a request query string: ?message=Serverless%20%2B%20Webtasks!.