Skip to content

Commit

Permalink
docs: update to sample in readme (#478)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored Oct 22, 2020
1 parent 86e5521 commit d349a9c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 35 deletions.
70 changes: 36 additions & 34 deletions packages/google-cloud-tasks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,44 +64,46 @@ 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,
async function quickstart() {
// 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',
},
};
}

const request = {
parent: parent,
task: task,
};
if (payload) {
task.appEngineHttpRequest.body = Buffer.from(payload).toString('base64');
}

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}`);
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}`);
}
quickstart();

```

Expand Down
2 changes: 1 addition & 1 deletion packages/google-cloud-tasks/synth.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"git": {
"name": ".",
"remote": "https://github.com/googleapis/nodejs-tasks.git",
"sha": "d0ecb6f6a9faf56c6e20145650bf35a545781f0b"
"sha": "a6b037d55fe90eb24424cd5a68390161d74cffe0"
}
},
{
Expand Down

0 comments on commit d349a9c

Please sign in to comment.