@@ -55,49 +55,49 @@ npm install @google-cloud/tasks
5555### Using the client library
5656
5757``` javascript
58- // Imports the Google Cloud Tasks library.
59- const {CloudTasksClient } = require (' @google-cloud/tasks' );
60-
61- // Instantiates a client.
62- const client = new CloudTasksClient ();
63-
64- // TODO(developer): Uncomment these lines and replace with your values.
65- // const project = 'my-project-id';
66- // const queue = 'my-appengine-queue';
67- // const location = 'us-central1';
68- // const payload = 'hello';
69-
70- // Construct the fully qualified queue name.
71- const parent = client .queuePath (project, location, queue);
72-
73- const task = {
74- appEngineHttpRequest: {
75- httpMethod: ' POST' ,
76- relativeUri: ' /log_payload' ,
77- },
58+ // Imports the Google Cloud Tasks library.
59+ const {CloudTasksClient } = require (' @google-cloud/tasks' );
60+
61+ // Instantiates a client.
62+ const client = new CloudTasksClient ();
63+
64+ // TODO(developer): Uncomment these lines and replace with your values.
65+ // const project = 'my-project-id';
66+ // const queue = 'my-appengine-queue';
67+ // const location = 'us-central1';
68+ // const payload = 'hello';
69+
70+ // Construct the fully qualified queue name.
71+ const parent = client .queuePath (project, location, queue);
72+
73+ const task = {
74+ appEngineHttpRequest: {
75+ httpMethod: ' POST' ,
76+ relativeUri: ' /log_payload' ,
77+ },
78+ };
79+
80+ if (payload) {
81+ task .appEngineHttpRequest .body = Buffer .from (payload).toString (' base64' );
82+ }
83+
84+ if (inSeconds) {
85+ task .scheduleTime = {
86+ seconds: inSeconds + Date .now () / 1000 ,
7887 };
79-
80- if (payload) {
81- task .appEngineHttpRequest .body = Buffer .from (payload).toString (' base64' );
82- }
83-
84- if (inSeconds) {
85- task .scheduleTime = {
86- seconds: inSeconds + Date .now () / 1000 ,
87- };
88- }
89-
90- const request = {
91- parent: parent,
92- task: task,
93- };
94-
95- console .log (' Sending task:' );
96- console .log (task);
97- // Send create task request.
98- const [response ] = await client .createTask (request);
99- const name = response .name ;
100- console .log (` Created task ${ name} ` );
88+ }
89+
90+ const request = {
91+ parent: parent,
92+ task: task,
93+ };
94+
95+ console .log (' Sending task:' );
96+ console .log (task);
97+ // Send create task request.
98+ const [response ] = await client .createTask (request);
99+ const name = response .name ;
100+ console .log (` Created task ${ name} ` );
101101
102102
103103```
0 commit comments