diff --git a/packages/google-cloud-tasks/README.md b/packages/google-cloud-tasks/README.md index 3b009ddccdd..49ef22fd571 100644 --- a/packages/google-cloud-tasks/README.md +++ b/packages/google-cloud-tasks/README.md @@ -55,49 +55,49 @@ npm install @google-cloud/tasks ### Using the client library ```javascript - // Imports the Google Cloud Tasks library. - const {CloudTasksClient} = require('@google-cloud/tasks'); - - // Instantiates a client. - const client = new CloudTasksClient(); - - // TODO(developer): Uncomment these lines and replace with your values. - // const project = 'my-project-id'; - // const queue = 'my-appengine-queue'; - // const location = 'us-central1'; - // const payload = 'hello'; - - // Construct the fully qualified queue name. - const parent = client.queuePath(project, location, queue); - - const task = { - appEngineHttpRequest: { - httpMethod: 'POST', - relativeUri: '/log_payload', - }, +// Imports the Google Cloud Tasks library. +const {CloudTasksClient} = require('@google-cloud/tasks'); + +// Instantiates a client. +const client = new CloudTasksClient(); + +// TODO(developer): Uncomment these lines and replace with your values. +// const project = 'my-project-id'; +// const queue = 'my-appengine-queue'; +// const location = 'us-central1'; +// const payload = 'hello'; + +// Construct the fully qualified queue name. +const parent = client.queuePath(project, location, queue); + +const task = { + appEngineHttpRequest: { + httpMethod: 'POST', + relativeUri: '/log_payload', + }, +}; + +if (payload) { + task.appEngineHttpRequest.body = Buffer.from(payload).toString('base64'); +} + +if (inSeconds) { + task.scheduleTime = { + seconds: inSeconds + Date.now() / 1000, }; - - if (payload) { - task.appEngineHttpRequest.body = Buffer.from(payload).toString('base64'); - } - - if (inSeconds) { - task.scheduleTime = { - seconds: inSeconds + Date.now() / 1000, - }; - } - - const request = { - parent: parent, - task: task, - }; - - console.log('Sending task:'); - console.log(task); - // Send create task request. - const [response] = await client.createTask(request); - const name = response.name; - console.log(`Created task ${name}`); +} + +const request = { + parent: parent, + task: task, +}; + +console.log('Sending task:'); +console.log(task); +// Send create task request. +const [response] = await client.createTask(request); +const name = response.name; +console.log(`Created task ${name}`); ```