Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use async/await in samples #193

Merged
merged 1 commit into from
Sep 20, 2018
Merged

Use async/await in samples #193

merged 1 commit into from
Sep 20, 2018

Conversation

JustinBeckwith
Copy link
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
Contributor

ace-n commented Sep 17, 2018 via email

@ofrobots
Copy link

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
Contributor

fhinkel commented Sep 20, 2018

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

@JustinBeckwith
Copy link
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
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
Contributor Author

So anyone willing to approve it then? 🤣

Copy link
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
Contributor Author

🤷‍♂️ I'll take it

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

@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!

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

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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