Skip to content
This repository was archived by the owner on Feb 7, 2026. It is now read-only.

Use async/await in samples#193

Merged
JustinBeckwith merged 1 commit intogoogleapis:masterfrom
JustinBeckwith:asyncy
Sep 20, 2018
Merged

Use async/await in samples#193
JustinBeckwith merged 1 commit intogoogleapis:masterfrom
JustinBeckwith:asyncy

Conversation

@JustinBeckwith
Copy link
Copy Markdown
Contributor

Mostly doing this to start a conversation :) What do y'all think of using async/await in our samples? I figure, we tell people to start with the latest LTS version of nodejs, which is 8 at this stage 🤷‍♂️ Node.js 6 is 6 months from death, so I don't feel too bad doing this just in the samples.

Thoughts?

@googleapis/node-team @fhinkel @ace-n

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Sep 17, 2018
@ghost ghost assigned JustinBeckwith Sep 17, 2018
@ace-n
Copy link
Copy Markdown
Contributor

ace-n commented Sep 17, 2018 via email

@ofrobots
Copy link
Copy Markdown

At this point it makes sense for the samples to assume async/await support. Node 6 will be EOL in April. It is declining in usage (see https://nodejs.org/metrics) and already Node 8 seems be getting 3x the downloads as Node 6.

@fhinkel
Copy link
Copy Markdown
Contributor

fhinkel commented Sep 20, 2018

Yeah, I think we can start with async/await samples.

@JustinBeckwith
Copy link
Copy Markdown
Contributor Author

@fhinkel what are your thoughts on the way I eliminated the error handling? We used to console.log the errors, now I am just letting the async method throw. Is this the pattern we want to roll with for our samples?

@fhinkel
Copy link
Copy Markdown
Contributor

fhinkel commented Sep 20, 2018

Looks good. You'd still see the error message in the stack trace, right? Maybe add one example that uses the async functions so we can show the catch block.

@JustinBeckwith
Copy link
Copy Markdown
Contributor Author

So anyone willing to approve it then? 🤣

Copy link
Copy Markdown
Contributor

@tswast tswast left a comment

Choose a reason for hiding this comment

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

Pretty!

(Not that my approval counts in nodejs-land)

@JustinBeckwith
Copy link
Copy Markdown
Contributor Author

🤷‍♂️ I'll take it

@JustinBeckwith JustinBeckwith merged commit 24a001d into googleapis:master Sep 20, 2018
Copy link
Copy Markdown

@ofrobots ofrobots left a comment

Choose a reason for hiding this comment

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

This is really nice!

Comment thread samples/queries.js
.catch(err => {
console.error('ERROR:', err);
});
const [rows] = await bigquery.query(options);

This comment was marked as spam.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants