Skip to content

Commit

Permalink
docs(samples): Update samples to use async/await (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
muraliQlogic authored and JustinBeckwith committed Nov 5, 2018
1 parent fa12e66 commit ce3c142
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions packages/google-cloud-dns/samples/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,19 @@
// Imports the Google Cloud client library
const {DNS} = require('@google-cloud/dns');

// Your Google Cloud Platform project ID
const projectId = 'YOUR_PROJECT_ID';
async function quickStart() {
// Your Google Cloud Platform project ID
const projectId = 'YOUR_PROJECT_ID';

// Creates a client
const dns = new DNS({
projectId: projectId,
});

// Lists all zones in the current project
dns
.getZones()
.then(results => {
const zones = results[0];

console.log('Zones:');
zones.forEach(zone => console.log(zone.name));
})
.catch(err => {
console.error('ERROR:', err);
// Creates a client
const dns = new DNS({
projectId: projectId,
});

// Lists all zones in the current project
const [zones] = await dns.getZones();
console.log('Zones:');
zones.forEach(zone => console.log(zone.name));
}
quickStart().catch(console.error);
// [END dns_quickstart]

0 comments on commit ce3c142

Please sign in to comment.