Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cloud-tasks): await async function & correct endpoint URL #4030

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cloud-tasks/tutorial-gcf/app/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ runtime: nodejs16
env_variables:
QUEUE_NAME: "my-queue"
QUEUE_LOCATION: "us-central1"
FUNCTION_URL: "https://<region>-<project_id>.cloudfunctions.net/sendEmail"
FUNCTION_URL: "https://<region>-<project_id>.cloudfunctions.net/send-email"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct: the Cloud Run function URL ends in /sendEmail; the app.post() seen below in the diff is the App Engine endpoint.

Suggested change
FUNCTION_URL: "https://<region>-<project_id>.cloudfunctions.net/send-email"
FUNCTION_URL: "https://<region>-<project_id>.cloudfunctions.net/sendEmail"

SERVICE_ACCOUNT_EMAIL: "<member>@<project_id>.iam.gserviceaccount.com"
# [END cloud_tasks_app_env_vars]

Expand Down
4 changes: 2 additions & 2 deletions cloud-tasks/tutorial-gcf/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading