This sample shows calling the success and failure callbacks.
View the documentation or the source code.
-
Follow the Cloud Functions quickstart guide to setup Cloud Functions for your project.
-
Clone this repository:
git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git cd nodejs-docs-samples/functions/module -
Create a Cloud Storage Bucket to stage our deployment:
gsutil mb gs://[YOUR_BUCKET_NAME]- Replace
[YOUR_BUCKET_NAME]with the name of your Cloud Storage Bucket.
- Replace
-
Deploy the
helloworldfunction with an HTTP trigger:gcloud alpha functions deploy helloworld --bucket [YOUR_BUCKET_NAME] --trigger-http- Replace
[YOUR_BUCKET_NAME]with the name of your Cloud Storage Bucket.
- Replace
-
Call the
helloworldfunction with some data:gcloud alpha functions call helloworld --data '{"message":"keyboard cat"}' -
Call the
helloworldfunction without any data:gcloud alpha functions call helloworldYou should see something like this in your console:
executionId: abcd1234-0 result: Hello World! -
Check the logs for the
helloworldfunction:gcloud alpha functions get-logs helloworldYou should see something like this in your console:
D ... User function triggered, starting execution I ... keyboard cat D ... Execution took 1 ms, user function completed successfully