Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

How can I use Cloud Tasks in frontend framework? #311

Closed
spider-hand opened this issue Nov 30, 2019 · 1 comment
Closed

How can I use Cloud Tasks in frontend framework? #311

spider-hand opened this issue Nov 30, 2019 · 1 comment
Assignees
Labels
api: cloudtasks Issues related to the googleapis/nodejs-tasks API. duplicate This issue or pull request already exists type: question Request for information or clarification. Not an issue.

Comments

@spider-hand
Copy link

spider-hand commented Nov 30, 2019

I am working on a project that is using Vue as frontend and Firebase as backend. And I was trying to use this client library in Vue component. However, this error happened.

Error: {"clientConfig":{},"port":443,"servicePath":"cloudtasks.googleapis.com","scopes":["https://www.googleapis.com/auth/cloud-platform"]}You need to pass auth instance to use gRPC-fallback client in browser. Use OAuth2Client from google-auth-library.

I attach my code just in case.

import * as tasks from '@google-cloud/tasks'

      addTasks() {
        const client = new tasks.CloudTasksClient()

        const projectId = process.env.VUE_APP_FIREBASE_PROJECT_ID
        const queue = 'night'
        const location = process.env.VUE_APP_FIREBASE_LOCATION_ID
        const parent = client.queuePath(projectId, location, queue)

        const task = {
          httpRequest: {
            httpMethod: 'POST',
            url: 'https://${location}-${projectId}.cloudfunctions.net/...',
            scheduleTime: {
              seconds: ...,
            }, 
          }
        }

        const request = {
          parent: parent,
          task: task,
        }

        client.createTask(request)
      },

How can I solve this? Or doesn't this library support frontend framework? I am in trouble because I have been using Firebase for the project's backend and don't want to set up custom backend.

Currently I created a cloud function to create a cloud task and then the cloud task will trigger other cloud function. But I am wondering if I can create a task from frontend framework directly because my current way seems inefficient.

@spider-hand spider-hand changed the title Is it possible to use Cloud Tasks in frontend framework? How can I use Cloud Tasks in frontend framework? Nov 30, 2019
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Dec 1, 2019
@bcoe bcoe added the type: question Request for information or clarification. Not an issue. label Dec 2, 2019
@bcoe
Copy link
Contributor

bcoe commented Dec 2, 2019

Hey @spider-hand, there's a discussion here as to how to get our gRPC libraries working in a front-end context 👍

@bcoe bcoe closed this as completed Dec 2, 2019
@bcoe bcoe added the duplicate This issue or pull request already exists label Dec 2, 2019
@google-cloud-label-sync google-cloud-label-sync bot added the api: cloudtasks Issues related to the googleapis/nodejs-tasks API. label Jan 31, 2020
@yoshi-automation yoshi-automation removed the triage me I really want to be triaged. label Apr 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: cloudtasks Issues related to the googleapis/nodejs-tasks API. duplicate This issue or pull request already exists type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

3 participants