From 29fc14b4dbb31eb565bceb93332820f1e27cc3a3 Mon Sep 17 00:00:00 2001 From: Ivan Hernandez Date: Wed, 19 Mar 2025 16:57:01 +0000 Subject: [PATCH] fix(cloud-tasks): add await to async function and correct endpoint path in FUNCTION_URL --- cloud-tasks/tutorial-gcf/app/app.yaml | 2 +- cloud-tasks/tutorial-gcf/app/index.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cloud-tasks/tutorial-gcf/app/app.yaml b/cloud-tasks/tutorial-gcf/app/app.yaml index c0edee0fe7..3000644a42 100644 --- a/cloud-tasks/tutorial-gcf/app/app.yaml +++ b/cloud-tasks/tutorial-gcf/app/app.yaml @@ -19,7 +19,7 @@ runtime: nodejs16 env_variables: QUEUE_NAME: "my-queue" QUEUE_LOCATION: "us-central1" - FUNCTION_URL: "https://-.cloudfunctions.net/sendEmail" + FUNCTION_URL: "https://-.cloudfunctions.net/send-email" SERVICE_ACCOUNT_EMAIL: "@.iam.gserviceaccount.com" # [END cloud_tasks_app_env_vars] diff --git a/cloud-tasks/tutorial-gcf/app/index.js b/cloud-tasks/tutorial-gcf/app/index.js index 97aea3b640..8dbae109d9 100644 --- a/cloud-tasks/tutorial-gcf/app/index.js +++ b/cloud-tasks/tutorial-gcf/app/index.js @@ -28,12 +28,12 @@ const {SERVICE_ACCOUNT_EMAIL} = process.env; app.use(express.urlencoded({extended: true})); // [START cloud_tasks_app] -app.post('/send-email', (req, res) => { +app.post('/send-email', async (req, res) => { // Set the task payload to the form submission. const {to_name, from_name, to_email, date} = req.body; const payload = {to_name, from_name, to_email}; - createHttpTaskWithToken( + await createHttpTaskWithToken( process.env.GOOGLE_CLOUD_PROJECT, QUEUE_NAME, QUEUE_LOCATION,